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 / abhijith

select top 10 *
from tablename
where city IN
(select distinct(city) from tablename)

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are different types of join?

769


What is it’s similarity with sql server?

143


What are the differences between substr and charindex in sql server.

509


How to optimize stored procedures in sql server?

636


How to attach adventureworkslt physical files to the server?

640






What is scheduled job and how to create it?

556


Using the customer, and order table in northwind database, please write a query to produce xml?

665


Do you know what are the restrictions that views have to follow?

632


What is dimension table? : sql server analysis services, ssas

566


You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?

112


What is the sql server agent?

593


how to create “alternate row colour”?

109


Where are SQL server users names and passwords are stored in sql server?

726


your distribution database is full what will u do

1683


How do I find my localdb version?

502