Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table(Table 1) like this :


col1 col2
1 ram
2 sham
3 ravi
4 mohit
5 mohan
6 subhash

and i have another query result(in temp table :#tempo) which is :

sham
subhash
ram
ravi
mohit
mohan


I want this resultant to be sorted in the sequence given in Table 1.

How do i do it .. PLease help !! it will be appreciated .Thanks in advance.
Posted
Updated 5-May-12 4:33am
v2

1 solution

Unless you have retained the col1 value with your col2 value when you generated your temp table, you can't - not easily. The only way to do it would be to backreference from the name to the original col1 and sort by that again. Which won't work unless the names are also unique.

I would modify my temp table to include the col1 and just use ORDER BY - it's a lot easier, and a lot more processor efficient.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900