Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the Main Difference between ACCESS and SQL SERVER?

1182


What are sql azure firewall rules?

106


Explain boyce and codd normal form(bcnf)?

1012


What is 'Join' and explain its various types.

1211


Why are sql functions used?

1182


Can we use where clause with group by?

948


How would you go about developing a ssrs report?

174


how many clustered indexes can be created on a table? : Sql server database administration

1223


Does union all remove duplicates?

1123


The external application that is executed in one of the tasks does not have a log file, but only a screen log. How can I save the data from the screen? : sql server management studio

1056


How to trouble shoot if unable to connect SQL Server

2031


How many clustered indexes there can be on table ?

1071


What is difference between index and primary key?

1137


What is xdr?

1041


Explain what is the main purpose of having conversation group?

986