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 Posted / ravi kumar ravuri

select * from Customer where Customer_ID in (select top 10
from Customer Where City_name in ( select City_Name from
Customer Group by City_Name))

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to check if a table is being used in sql server?

523


Does sql server 2000 full-text search support clustering?

512


What is the difference between functions and stored procedures?

625


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

586


What is a recursive stored procedure in sql server?

578






If a user does not have permission to a table, but has permission to a view created on it, will he be able to view the data in table?

559


how to trace the traffic hitting a sql server? : Sql server database administration

1146


What encryption security is available in sql azure?

81


Can you please explain the difference between primary keys and foreign keys?

664


ow to bring suspect mode datbase online from scratch

1415


What is delete query?

529


How to drop an existing schema in ms sql server?

604


What is the meaning of sql server?

535


What is difference in performance between insert top (n) into table and using top with insert?

543


what is a live lock? : Sql server database administration

506