Subject Re: [firebird-support] How can I correctly write this WHERE
Author Tomasz Tyrakowski
Hi,

As I understand it, what you meant is:

where
(
TRIM(vwTA.cNameCity01) = 'Balance Sheet' and CAST(tSI.tDt AS DATE) <
'2018-04-01'
)
or
(
TRIM(vwTA.cNameCity01) is distinct from 'Balance Sheet'
and CAST(tSI.tDt AS DATE) BETWEEN '2018-03-01' AND '2018-03-31'
)

If vwTA.cNameCity01 is sure to be not null, you can put a plain <> in
place of "is distinct from".
This condition is different from what Svein posted an hour ago, but the
above is how I understand your _intention_ in your WHEN condition (I
might be wrong, though ;) ).

cheers
Tomasz

On 19.06.2018 o 10:25, venussoftop@... [firebird-support] wrote:
> 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
>
>


--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__