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

When to use Inner join & when to use subquery?

564


Explain the stored procedure?

607


Explain about extended stored procedure?

470


Can you explain powershell included in sql server 2008?

489


Explain about Views?

590






How can you start sql server in different modes?

489


Why union all is faster than union?

481


what are acid properties? : Sql server database administration

474


What is the use of RDBMS?

556


Explain sub-query?

553


What does <> symbol mean?

527


What is update_statistics command?

554


What are advantages of ssrs or why we should use ssrs?

104


Explain what is lock escalation and what is its purpose?

489


Can a function call a stored procedure in sql server?

506