ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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
 Question Submitted By :: Praveen.kumar4u1093
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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 1 No
Pradip Jain
 
  Re: 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
# 2
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
Ram Birendra Jha
 
 
 
  Re: 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
# 3
Hi Ram, what new you are done man?
you have posted same answer as me.
 
Is This Answer Correct ?    0 Yes 0 No
Pradip Jain
 
  Re: 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
# 4
this is not right query beacuse if table contain 1000 
record then you need to give 1000 condition .so it is not 
right answer
 
Is This Answer Correct ?    0 Yes 0 No
Praveen Kumar
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
how to find out the repeated value from table using groupby function?  3
What is Covering Indexes? Plz explain with example  2
when inserting to a table how many rows will be effected using triggers  1
Rate yourself in .NET and SQL ? Cognizent1
what is web server? Satyam3
In clustered and non clustered indexes which one is faster while executing a query ?  1
What is user stored procedure & it purpose? Wipro3
What is de-normalization and when do you do it?  3
How do you find the number of rows in a table?  5
What is cursor ? And what is difference between Trigger ? HCL1
What is the difference between IN and EXISTS operators in SQL Server? Intelligroup3
what is Constraint? How many types of constraints in SQL ? NIIT7
How to write stored procedure to update the data in 10 tables  4
What is the use of MOVE keyword in restore command IBM2
How do you load large data to the SQL server database?  2
what is cluster and nin-cluster index?  4
can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com Symphony21
About DTS usage ? Cognizent2
When do you create cluster and noncluster index? Satyam4
write coding for importing sql data into a word excel... Oracle1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com