Subject | Re: [firebird-support] How can I correctly write this WHERE |
---|---|
Author | livius |
Post date | 2018-06-21T18:40:58Z |
Hi,
is this your real query? I ask, because below WHERE can be not
intentionaly written by OR
WHERE (
heir.iaccttreeid = 47
AND cast(tsi.tdt AS date) < '2018-04-01' )
OR (
heir.iaccttreeid <> 47
AND cast(tsi.tdt AS date) BETWEEN '2018-03-01' AND '2018-03-31' )
AND tsi.cdoctype NOT LIKE 'PROFORMA%'
AND tsi.cdoctype NOT LIKE 'CANCELLED%'
AND ssifooter.cdrcr IN ('DR',
'CR')
heir.iaccttreeid = 47
AND cast(tsi.tdt AS date) < '2018-04-01' )
OR (
heir.iaccttreeid <> 47
AND cast(tsi.tdt AS date) BETWEEN '2018-03-01' AND '2018-03-31' )
AND tsi.cdoctype NOT LIKE 'PROFORMA%'
AND tsi.cdoctype NOT LIKE 'CANCELLED%'
AND ssifooter.cdrcr IN ('DR',
'CR')
i suppose you need more parenthesis:
WHERE
(
(
heir.iaccttreeid = 47
AND
cast(tsi.tdt AS date) < '2018-04-01'
)
OR
(
heir.iaccttreeid <> 47
AND
cast(tsi.tdt AS date) BETWEEN '2018-03-01'
AND '2018-03-31'
)
)
AND tsi.cdoctype NOT LIKE 'PROFORMA%'
AND tsi.cdoctype NOT LIKE 'CANCELLED%'
AND ssifooter.cdrcr IN ('DR',
'CR')
regards,
Karol Bieniaszewski