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

How to verify the port number of the sql server?

529


What are the components of dbms?

511


How to use go command in "sqlcmd"?

628


how can you check the level of fragmentation on a table? : Sql server administration

523


What is the use of floor function in sql server?

515






What is the need for indexing?

484


What are the different SQL Server Versions you have worked on?

523


how many layers of tcp/ip protocol combined of? : Sql server database administration

494


Explain insert into select statement?

499


What is clustered vs nonclustered index?

488


When a primary key constraint is included in a table, what other constraints does this imply?

573


Define outer join?

517


What are the reporting services components?

90


Do you know what is replace and stuff function in sql server?

444


What is stored procedures?

527