Isnull get the next SQL condition

Asked

Viewed 47 times

0

how can I do on SQL server a condition if the return of a field is null and it returns another condition

ISNULL( CONVERT(CHAR(08),C.PEDS_DAT_FAT,112), d.NFFE_DAT_ENT) BETWEEN '20180501' AND '20180530')

basically is the C.PEDS_DAT_FAT it returns normal and if it is null it in my thought would have to go to the d.NFFE_DAT_ENT but it does not bring the result

  • Please enter more information of the query. The ISNULL is in the select or in the Where?

  • Hello thank you, he’s in where .

  • if PEDS_DAT_FAT for null, use NFFE_DAT_ENT ?

  • Yes more when I do it this way that is comes the null field with no date being that has record on condition of Nffe_dat_ent

  • puts your whole query, and the structure of the tables. If possible make an example in Sqlfiddle

1 answer

0

From what I understand you should check if the field is null before the conversion; then it would look like this:

CONVERT(CHAR(08), ISNULL(C.PEDS_DAT_FAT, d.NFFE_DAT_ENT), 112)
BETWEEN '20180501' AND '20180530'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.