Re: Order By - Conditional
From: Wes (anonymous_at_discussions.microsoft.com)
Date: 09/15/04
- Previous message: Anith Sen: "Re: passwrd"
- Next in thread: Hugo Kornelis: "Re: Order By - Conditional"
- Reply: Hugo Kornelis: "Re: Order By - Conditional"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 10:14:33 -0700
I have tried the following but with no success...
ORDER BY CASE WHEN Status > 11 THEN Name END,
CASE WHEN Status <= 11 THEN Order_ID END
Is there any other approach I can use?
Thanks in advance
>-----Original Message-----
>On Fri, 13 Aug 2004 05:04:53 -0700, Wes wrote:
>
>>I wish to include a condition in my order by statement.
>>
>>i.e. If the value of Field X > Y then Order by Field X,
>>else Order by Field Z.
>>
>>I have tried inserting a select case but i cannot get it
>>to work
>>
>>Here is an extract from the table
>>Order_ID Status Name
>>50 10 Michael
>>51 10 John
>>52 10 Peter
>>53 20 Adam
>>54 20 Bruce
>>
>>The condition I would like to apply is as follows:
>>If Status is greater than 11, Order by Name, else order
by
>>Order_ID
>>
>>Any help wpuld be greatly appreciated
>
>Hi Wes,
>
>Something like this?
>
>ORDER BY Status,
> CASE WHEN Status > 11 THEN Name END,
> CASE WHEN Status <= 11 THEN Order_ID END
>
>
>Best, Hugo
>--
>
>(Remove _NO_ and _SPAM_ to get my e-mail address)
>.
>
- Previous message: Anith Sen: "Re: passwrd"
- Next in thread: Hugo Kornelis: "Re: Order By - Conditional"
- Reply: Hugo Kornelis: "Re: Order By - Conditional"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|