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
List few advantages of stored procedure.
List some of the rules that apply to creating and using a ‘view’
What are sub reports and how to create them?
How to optimize stored procedure optimization?
How to delete a database in ms sql server?
What is a trigger and types of a trigger?
What are the 2 types of classifications of constraints in the sql server?
How do I start sql server 2017?
Explain the relational database management system (rdbms)?
Define inner join? Explain with an example?
How can I add Reporting Services reports to my application?
What program is used to store the data source file?
Can I save my report as html, excel or word? : sql server management studio
Explain the properties of the relational tables?
What is the difference between stored procedure and user defined functions?