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

How do you implement session management in SQL Server mode?

723


What do you understand by coalesce in sql server?

726


What are the purpose of Normalisation?

802


What is the dbcc command and why is it used?

764


What is difference between primary key and foreign key?

651






What do you understand by sql server agent?

686


Can we install sql server 2016 on windows 7?

867


what are the different types of SSRS reports?

122


How to connect sql server management studio express to sql server 2005 express?

753


What is the new security features added in sql server 2014? : sql server security

758


You have a table ‘test’ which is a copy of northwind employee table you have written a trigger to update the field ‘hiredate’ with the current date

820


What is the difference between set and select?

744


When does the auto update index statistics feature in sql server turn itself on?q) what specific conditions database should meet, before you can bulk copy data into it using bcp?

756


What is difference between Datepart() and Datename() in SqlServer?

907


Describe the functionalities that views support.

847