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.
Author |
Topic |
grimmus
Yak Posting Veteran
53 Posts |
Posted - 2012-01-10 : 04:20:23
|
Hi,I have a resultset that contains between 3 and 10 rows. Each result has an ID and i need to order the rows in the following wayID718then the others here, if relevantIs there a way that I can explicitly say that i want rows with ID 7,1,8 to appear at the top of the resultset ? There is no other column that could help with the ordering at this point.Thanks in advance |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-10 : 04:25:10
|
you can do something like..ORDER BY CASE Yourfield WHEN 7 THEN 0 WHEN 1 THEN 1 WHEN 8 THEN 2 ELSE 3 END,Yourfield ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
grimmus
Yak Posting Veteran
53 Posts |
Posted - 2012-01-10 : 04:58:04
|
excellent , thank you. Ill give it a shot. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-10 : 06:43:44
|
welcome...let us know how you got on------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|