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 |
|
jhon11
Starting Member
42 Posts |
Posted - 2008-01-23 : 10:19:03
|
| Hi,I have a table in which there is 5 column ...one with numbers like...1,2,3,4,..20...and one column is with description....and other column with other details...Now I want to disply my results in sequence followed by 1,2,3,4,5,17,18,15,16,10,11,20 with all other columns...so can anybody suggest me what to do..? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-01-23 : 10:24:04
|
| create a temp table with that sequenceid int, sequence intjoin on the id and order on the sequence_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out |
 |
|
|
jhon11
Starting Member
42 Posts |
Posted - 2008-01-23 : 10:48:00
|
| hi,how could i do the temp table..i couldnt get the logic... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-23 : 11:21:14
|
| [code]create table #temp(yourcol int,SeqNo int)INSERT INTO #tempSELECT 1,1UNION ALLSELECT 2,2....SELECT 17,6UNION ALLSELECT 18,7UNION ALLSELECT 15,8...Then takeSELECT t1.*FROM YourTable t1INNER JOIN #temp t2ON t2.YourCol=t1.YourColORDER BY t2.SeqNo[/code] |
 |
|
|
|
|
|
|
|