Skip to content
Advertisement

‘An expression of non-boolean type specified in a context where a condition is expected, near ‘,’.’ when date between

I am creating a sql query and I want to make profit and loss report but I’ve got this error in my query:

‘An expression of non-boolean type specified in a context where a condition is expected, near ‘,’.’

How can I fix this?

Advertisement

Answer

Just by identing your SQL command, it’s possible to see that there’s something wrong in it, look:

On the WHERE clause you are using a list of 3 columns to compare to the date range using BETWEEN. That’s not how it works. If your intention is to consider the 1st column and if it is null, consider the second and if it is also null, consider the 3rd, you should use the COALESCE function. Like that:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement