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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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
 
What are the differences between stored procedure and functions in SQL Server 2000? TCS12
I have a website that allows customers to browse and place orders for certain products. I have 2 tables; Customers and Orders. The Customers table holds the customer records and the Orders table holds the orders placed by the customer. Both tables are tied based on the field Cust_ID. Example of the data is shown below: Cust_ID Cust_Name Cust_ID Product Amount Order_Date 1001 John Tan 1001 P-5211 $120.00 2/13/2006 1002 Michael Wong 1001 K-1428 $88.90 1/11/2006 1003 Mary Cheong 1003 C-0923 $82.50 1/27/2006 1004 Ahmad Suffian 1003 K-1428 $88.90 2/2/2006 Write a single SQL statement that extracts all purchase records with the following criteria: 1. Customer names starting with “M” only. 2. Orders placed within the current month only. 3. Amount does not exceed $100.00 The list must be sorted by order date with the latest order showing on top. Techno-Solutions3
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? HCL1
what is the difference between Delete and Truncate Geo-Research-Centre3
What is deadlock and how to avoid the deadlocks. Wipro3
what is hash table Teledata2
what is the order of execution of where,having,group by in select stement Tanla-Solutions5
Hi Can any one tell me the Good institute to learn SQL esp for Data Base Testing or SQL from scratch to the proficiency level in Hyederabad and facult also. Thankyou well in advance  6
How do I list the available tables in a database I'm querying?  3
Assume,there are three tables in a database, Can i have both primary key and foreign key for each table in the same database?  4
What is a transaction and what are ACID properties? IBM4
What is blocking and how would you troubleshoot it? HCL2
Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?  2
how to get 25th row in any table in sqlserver can u tell me syntax  4
how can i store resumes in database? HCL2
What is the use of DBCC commands?  1
how to find out the repeated value from table using groupby function?  3
What are the two virtual tables SQL Server maintains for triggers?  2
How to Run a Query on a Remote SQL Server?  2
How to Display, Amount of Disk Activity Generated by Transact-SQL Statements?  1
 
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