I have a SQL which gets data until yesterday by using where clause as " Where tpd."RELATIVE_GLOBAL_DAY" = -1 " The db is defined as such that when I want to get todays data, I will have use 0 and likewise for yesterdays data, I can use -1 and for day before -2.
My query works fine except on monday. As per the query it gives me data of Sunday which I don't want. Instead I need data from last monday to friday all together but when its Tuesday I only need data for previous day which in this case should be Monday.
How do I put this condition in the where clause.
Thanks
tpd."RELATIVE_GLOBAL_DAY" = -1
As long as you have a column which has the current weekday or the current date, you can use
ORto take care of these two situations. For example:Here I am assuming you have a column
daywhich indicates the current day of the week. If you do not, but you have a columndatewhich indicates the current date, replacedayabove withDATEPART('weekday',date).