Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select order by group

Author  Topic 

Nickel
Starting Member

2 Posts

Posted - 2005-08-31 : 08:32:38
Hi all,

I have a query below with Northwind db.

select productname from products where categoryID in (6,2,7) order by categoryID

Could anyone please help me to display the products in the given category order as 6,2,7.

Thanks in advance,
Nickel.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 08:37:53
Try this

select productname from products where categoryID in (6,2,7) order by
case when Categoryid=6 then 1 when Categoryid=2 then 2 when Categoryid=7 then 3 end


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Nickel
Starting Member

2 Posts

Posted - 2005-08-31 : 10:21:44
Thanks Madhi.
Go to Top of Page
   

- Advertisement -