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 is a view in sql?

582


What are cursors stored procedures and triggers?

515


How do you use a subquery to find records that exist in one table and do not exist in another?

548


What is use of except clause?

629


Can we add an identity column to decimal datatype?

584






Why use update_statistics command in sql server?

558


What is the full meaning of dml?

530


Explain iaas, paas and saas?

74


Is truncate a dml command?

503


What are the different types of collation sensitivity in sql server?

586


How to use copy and concatenate commands in SQL?

601


What is database black box testing?

605


What is sql server programming?

553


What is the difference between dropping a database and taking a database offline?

698


How many database files are there in sql server 2000?what are they?

581