Subject | How can I correctly write this WHERE |
---|---|
Author | |
Post date | 2018-06-19T08:25:10Z |
Hi all
I am trying to write a conditional WHERE clause but it fails. Please suggest a correct way to write this
WHERE CASE WHEN TRIM(vwTA.cNameCity01) = 'Balance Sheet'
THEN CAST(tSI.tDt AS DATE) < '2018-04-01'
ELSE CAST(tSI.tDt AS DATE) BETWEEN '2018-03-01' AND '2018-03-31' END
vwTA and tSI are all joined into the query and the error I receive is
Message: isc_dsql_prepare failed
SQL Message : -104
Invalid token
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 35, column 29
<
This is the < in the THEN clause
Please advise
Kind regards
Bhavbhuti