Two examples of evaluating 2 values and returning a given value based on which is earlier/bigger:
DECODE((SYSDATE - A.DUE_DT) - ABS(SYSDATE - A.DUE_DT), 0, 'OVERDUE', A.DUE_DT) AS DUE_DATE
CASE WHEN SYSDATE > A.DUE_DT THEN 'OVERDUE' ELSE to_char(A.DUE_DT) END AS DUE_DATE
Both do the same thing.
Related links:
http://www.4guysfromrolla.com/webtech/102704-1.shtml
http://www.sqlteam.com/article/the-case-for-case
Decode, If, Case statements in SQL
Posted by
Michael Nitschke
on Tuesday, 4 December 2007
Labels:
SQL Decode If Case
/
Comments: (0)