Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Immediately exit a query if a condition is verified - response (13) by Terry_Fisher

$
0
0

You can use the EXISTS clause as follows:
 
SELECT *
FROM    a_really_big_table
WHERE EXISTS
           (SELECT day_of_week
                FROM sys_calendar.calendar
               WHERE day_of_week = 2 -- is it a Monday
               AND calendar_date = date -- check todays date
          )
;

Teradata will immiediately determine whether the subquery returns an empty result set, and if so, will not even attempt to execute the outer query.
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>