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 / 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 is data compression?

1066


What does sql server mean?

1162


What is cdc in sql server?

1045


Suppose we have a table "MyTable" containing 10 rows, what query should be executed to update the odd rows "Salary" as 9000?

1030


Write query to return all rows sql?

1110


What is exporting utility?

1086


What is the boxing and unboxing concept in .net?

976


What are the steps you should follow to start sql server in single-user mode?

951


How much space does sql server 2016 take?

1033


When does the auto update index statistics feature in sql server turn itself on?q) what specific conditions database should meet, before you can bulk copy data into it using bcp?

1032


Can you explain what are the restrictions applicable while creating views? : SQL Server Architecture

967


Explain what is it unwise to create wide clustered index keys?

1023


What is the use of toad or sqldbx.?

1201


Explain stored procedure?

1108


whats the maximum size of view state??

2248