Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

CASE statement - response (1) by dnoeth

$
0
0

Hi Cheeli,
according to the manuals "IF the THEN/ELSE clause expressions  contain a DateTime or Interval data type then  all of the THEN/ELSE clause expressions must have the same data type." 
So there will be an automatic (implicit) typecast and the rule for comparing DATE and TIMESTAMP is "The TIMESTAMP value is always converted to DATE in case of comparison." 
When i first noticed this rule i didn't find it very intuitive:
SELECT 'true' WHERE CURRENT_DATE = CURRENT_TIMESTAMP;
 
As a rule of thumb: When you have DATE and TIMESTAMP in a comparison/CASE you have to CAST the DATE to a TIMESTAMP explicitly.
 
In your case the optimizer seems to do the automatic typecast first and then applies the algorithm to simplify the expression and removes the FALSE part.
 
 
Dieter
 
 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



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