I want to see data for previous day in our reports.
Thus all I am doing is : Sel * from table where date_col= Current_Date-1.
However when it a Monday , it has to extarct the data for the last Friday.
Thus Current_Date-1 will not work here.
Any optimized way to perform this , experts?
CASE WHEN is your friend.
WHERE date_col = CURRENT_DATE - (CASE WHEN ((CURRENT_DATE - DATE '1900-01-01') MOD 7) + 1 <> 1 THEN 1 ELSE 3 END)
Another solution with the same idea behind Carlos' solution :
select * from Table where date_col = current_date - case current_date when trunc(current_date, 'iw') then 3 else 1 end;