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
A table contains list of customers and his city with other 
details. Each customer has a unique number and the table 
consists millions of data. Query is: I want to retrieve 10 
customers from each city, no script, only from single query?
 Question Submitted By :: Manub22
I also faced this Question!!     Rank Answer Posted By  
 
  Re: A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query?
Answer
# 1
select Top 10 CustomerName, city from customer
 
Is This Answer Correct ?    5 Yes 15 No
Sonal Parekh
 
  Re: A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query?
Answer
# 2
SELECT A.*  
FROM dbo.T1 A 
WHERE CustomerID IN 
 (SELECT TOP 10 CustomerID FROM dbo.T1 WHERE City=A.City)
 
Is This Answer Correct ?    11 Yes 3 No
Grace
 
 
 
  Re: A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query?
Answer
# 3
select id,addressid,city
from
(
	SELECT ROW_NUMBER() OVER (partition by city Order by 
addressid) ID,AddressID,City
	FROM person.Address A 
	WHERE City IN 
		(select city from person.address group by City  
 
 ) )a
	where a.ID <11 
order by City,ID
 
Is This Answer Correct ?    1 Yes 0 No
Asim
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What are user defined datatypes and when you should go for them?  1
How to select nth record from a table? DELL9
When do you create cluster and noncluster index? Satyam4
How To Make password Protected SQL Server 2005 Database i.e when i open SQL Server database then ask for password.  1
How do I list the available tables in a database I'm querying?  3
internal language used in sql server 2000?  1
Is it possible to create tables in stored procedures using a variable for the table name?  2
What is the difference between OLEDB and ODBC CFCI3
Difference between writing SQL query and stored procedure ? Cognizent8
I need a query that retrieves info from an Oracle table and a query that retrieves info from a SQL Server table. The info has to be joined together according to Record ID numbers. I have very limited access to the Oracle database but full control of the SQL Server database.How do I join two different queries from two different databases?  1
what is the cursor life span? Evalueserve5
Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?  2
Explain Different types of Projects?  1
please tell me the query to get details of the employee having the second largest salary 247Customer8
can you any body tell me which service pack is installed in the sql server?  3
What is referential integrity and how is it achieved? Adea-Solutions1
When do we use the UPDATE_STATISTICS command?  3
Can you explain the types of Joins that we can have with Sql Server?  2
What is the datatype returned by count(*) Asian-CERC18
What are three SQL keywords used to change or set someone?s permissions?  3
 
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