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 fastest way to permanently delete a 1 million row table named customers?

1155


What is buffer cash and log cache in sql server?

1056


Can multiple columns be used in sql group by clause in ms sql server?

988


When is update_statistics command used?

998


What is the full form of dql?

929


what is the difference between a primary key and a unique key? : Sql server database administration

948


What is dirty read?

1042


How to create indexed view?

987


What is difference between rownum and row_number?

911


explain what is a deadlock and what is a live lock? How will you go about resolving deadlocks? : Sql server database administration

864


What are the purpose of Normalisation?

1002


what number files will a information contain in SQL Server? How many forms of information files exist in SQL Server? How many of those files can exist for a single database?

987


How do I perform an unattended install of sql server 2000?

1020


What are the advantages of sql azure?

139


What are the new features in SQL Server 2005 when compared to SQL Server 2000?

1089