i have a table #temp1(id, Name groupname ) and record
like this 1 R1 S
2 R3 S
3 R2 S
4 R4 D
5 R5 D
6 R6 K
7 R7 K
8 R8 L
9 R9 L
10 R10 L
11 R11 K
and i want to display record based on user defind sorting
order e.g.
1 R4 D
2 R5 D
3 R6 K
4 R7 K
5 R11 K
6 R1 S
7 R3 S
8 R2 S
9 R8 L
10 R9 L
11 R10 L
Answer Posted / ram birendra jha
SELECT
case name
When 'R4' then 1
When 'R5' then 2
When 'R6' then 3
When 'R7' then 4
When 'R11' then 5
When 'R1' then 6
When 'R3'then 7
When 'R2'then 8
When 'R8' then 9
When 'R9' then 10
When 'R10' then 11
END as Id,
name,groupname FROM Tempid
ORDER BY Id
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is resource db in sql server?
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
Differentiate sql server reporting services vs. Crystal reports?
What are system databases into sql server (2005/2008) : sql server database administration
What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?
What is sql server query analyzer?
Can we add our custom code in ssis?
what authentication modes does sql server support? : Sql server database administration
Explain “not null constraint” in sql server?
What is executereader?
In which format does an image save in SQL Server database ?
Describe triggers features and limitations?
Why would you call update statistics?
What xml support does the sql server extend?
List out some of the requirements to set up a sql server failover cluster?