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 / pradip jain

SELECT
case name
When 'R4' then 1
When 'R5' then 2
When 'R6' then 3
When 'R7' then 4
When 'R8' then 5
When 'R9' then 6
When 'R10'then 7
When 'R11'then 8
When 'R1' then 9
When 'R2' then 10
When 'R3' then 11
END as RID,
name,groupname FROM TEMP1 T1
ORDER BY RID

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens if you add a new index to large table?

504


How to specify the collation for a character data type in ms sql server?

541


What is the difference between the export /import functions in sql studio and standalone sql manager? : sql server management studio

583


Explain the Ways to improve the performance of a sql azure database?

62


Explain about analysis services?

569






when you create a database how is it stored? : Sql server database administration

483


Do you know what is user defined datatypes and when you should go for them?

492


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

560


What is tablesample?

564


Define right outer join?

540


What stored by the model? : sql server database administration

537


What is compression - row-level and page-level compression?

520


What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas

533


Why truncate is ddl?

598


Explain full-text query in sql server?

527