Teradata SQL Asst query - Error in where clause

62 views Asked by At

I have included one 'where' clause which I was hoping to return output with reference to current_date but I am getting an error. Can someone please take a look at it and let me know what exactly I am doing wrong here. Snap attached here.

                      AND CASE WHEN (SELECT
                                        CASE TD_Day_of_Week (CURRENT_DATE)
                                        WHEN 1 THEN 'MON'
                                        WHEN 2 THEN 'TUE'
                                        WHEN 3 THEN 'WED'
                                        WHEN 4 THEN 'THU'
                                        WHEN 5 THEN 'FRI'
                                        WHEN 6 THEN 'SAT'
                                        WHEN 7 THEN 'SUN'
                                        ELSE 'Unknown'
                                        END) <> 'MON' THEN tpd."RELATIVE_GLOBAL_DAY" = -1
                                        ELSE tpd."RELATIVE_GLOBAL_DAY" = -3 
                                        END
1

There are 1 answers

7
Tim Biegeleisen On

It appears that the intention here is to restrict the TD_Day_of_Week day of the week to not being Monday. If so, then just directly add that assertion, sans the bulky CASE expression:

WHERE (TD_Day_of_Week (CURRENT_DATE) <> 1 AND tpd."RELATIVE_GLOBAL_DAY" = -1) OR
      tpd."RELATIVE_GLOBAL_DAY" = -3