Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Case statement with a select & date in it

2949768May 13 2015 — edited May 19 2015

Good Morning Everybody,

This is my first discussion so please bare with me.

I am trying to write a case statement that has a select statement in it that compares dates.

When I write a case statement with a select in it that compares anything but dates it works just fine.  Once the date gets in there it falls apart.

Below is a super simple example of what I am trying to do, "b.in_serv_dt" is a date

select unit_no,

case when ((select b.in_serv_dt from unit_dept_comp_main b where a.unit_id = b.unit_id and b.in_serv_dt) >= '01-JAN-2012') then 'everybody wins'

  when ((select b.in_serv_dt from unit_dept_comp_main b where a.unit_id = b.unit_id and b.in_serv_dt) <= '01-JAN-2012') then 'nobody wins'

end

from ottawa_unitmain_v a

Any help would be greatly appreciated

Thank you very much

This post has been answered by BrunoVroman on May 13 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2015
Added on May 13 2015
5 comments
3,145 views