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!

Between clause with DECODE function.

494282Jul 24 2008 — edited Jul 25 2008
Hi All,

I have one table which has object, date and quantity columns, Now based on date range I can find out the objects and quantity but the question is: I want a query which returns all the objects and should show quantity 0(zero or null) for those objects which don't falls under that date range. So I thought to use a decode function but it only uses the relational operation, I thought something like this but it's wrong,

select object,decode(created_date,BETWEEN '01/01/2008' TO '08/01/2008',quantity,0) from table;

Does anyone have any idea how can I make this work in single sql statement?

Thanks for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2008
Added on Jul 24 2008
8 comments
3,960 views