By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

db2 CASE statement in ORDER BY clause

P: 1
Hi all !

This is my first post here. I am totally new to db2 and last night I faced with this problem:

I want to order my query results by different columns in ORDER BY clause using CASE statement as follows:

DECLARE cursor1 CURSOR WITH RETURN FOR
.....
....
.....
ORDER BY( CASE WHEN ORDER_MODE = '1' THEN 2 ELSE 5 END )

Of course this does not work (I don't know why ). When I write:

ORDER BY( CASE WHEN ORDER_MODE = '1' THEN 5 ELSE 5 END )

This also does not work.

When I write:

ORDER BY ( 5 )

It's working fine, but there is no CASE so it;s not my intention.

Does anybody knows what can be wrong with my statement ?
Thanks for help in advance.
Aug 25 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.