using CASE in SQL Query
we have a query, that runs just fine. Here is how the query looks like
select ... column names .....
from ...... table_name A, table_name B
where COL_A = 1026 AND COL_B='DELETED'
AND
((a.col1_date >= to_date(sysdate-1,'dd-mm-yyyy') and
a.col2_date < to_date(sysdate, 'dd-mm-yyyy')) OR
(b.col1_date >= to_date(sysdate-1,'dd-mm-yyyy') and
b.col2_date < to_date(sysdate, 'dd-mm-yyyy')))
group by a.col,b.col.....
We run this query every morning and get the desired results but on Monday mornings, we need to replace the "sysdate-1" in the above code with "sysdate-3"
so we came up with this
select ... column names .....
from ...... table_name A, table_name B
where COL_A = 1026 AND COL_B='DELETED'
AND
((a.col1_date >= to_date(sysdate-1,'dd-mm-yyyy') and
a.col2_date < to_date(sysdate, 'dd-mm-yyyy')) OR
(b.col1_date >= to_date(sysdate-1,'dd-mm-yyyy') and
b.col2_date < to_date(sysdate, 'dd-mm-yyyy')))
group by a.col,b.col.....
We run this query every morning and get the desired results but on Monday mornings, we need to replace the "sysdate-1" in the above code with "sysdate-3"
so we came up with this
0