Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

case statement to decode

Jim PDec 5 2007 — edited Dec 7 2007

Hello,
I am used to using case within my select statements, I need to use decode if possible for this one. Its for a record group within in forms, and the case statement is not working. Could someone please help me write this with decode instead of case?

SELECT CASE
       WHEN months_between(sysdate , c.birth_dt) BETWEEN 168 AND 216 THEN 1 --14 to 18
       WHEN months_between(sysdate , c.birth_dt) BETWEEN 217 AND 252 THEN 2 --18 to 21
       WHEN months_between(sysdate , c.birth_dt) BETWEEN 253 AND 780 THEN 3 --21 to 65
       WHEN months_between(sysdate , c.birth_dt) > 780 then 4 --older than 65
       ELSE NULL END 
FROM mw_clients c

Thanks in advance!
Jim P.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2008
Added on Dec 5 2007
23 comments
8,226 views