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 ?    2 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are constraints? Explain different types of constraints? : Sql server database administration

510


What is user-defined function?

582


Is it possible to update the views? If yes, how, if not, why?

553


What happens on checkpoint?

624


How to write a query with an inner join in ms sql server?

560






What is global temp table?

578


Explain how does the report manager work in ssrs?

505


Explain magic tables in sql server?

559


What are the steps to follow to configure SQL*Net?

567


What is the difference between for xml raw and for xml auto?

579


What is partition in sql server?

543


Do you know the different ddl commands in sql?

597


What is save transaction and save point?

630


What is report server project?

106


can any body tell me how to know the password of current user in sql server

1589