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 / getaway
Very vague question!
The asker did not give an explanation of the desired sorting rule. Without that the closest answer is to sort based on Order by groupname, name
Of course specifying the query's output through CASE..WHEN.. is the "smartest" idea. If you give me this answer at the job interview, I positively won't hire you. As it was mentioned in answer #4, what if the table has 1000 rows? And in a week - 5000? How you gonna manage your query?
Good luck.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is row_number function?
How do I repair damaged sql server mdf file database? In previous day my mdf file has got damage due to unknown reasons then I used dbcc chekcdb command but it failed, MDF file is important for me, I don’ know that how to get back mdf file data. Please anyone suggest me?
can a table be moved to different filegroup? : Sql server administration
Relational calculus is what type of language?
What are the different types of subquery?
What is 'Join' and explain its various types.
What samples and sample databases are provided by microsoft?
Can we linked SharePoint to a SQL database?
What are the acid properties?
Can sub report data source be different from that of the parent report?
Explain what are magic tables in sql server?
Can you explain what is sql server english query?
What guidelines should be followed to help minimize deadlocks?
What do you mean by data manipulation language?
What are Row versions of DataRow?