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 happens when converting big values to numeric data types?

574


What methods do you follow to protect from sql injection attack?

521


What are the properties of the transaction?

555


Are there issues when exporting SSRS reports into Microsoft Excel? When my users are trying to export a SSRS report into Microsoft Excel, one or two columns in the report appear to merge together. Why might this be?

134


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

502






Why does sql studio use a single registered database repository? : sql server management studio

540


What do you mean by an execution plan? How would you view it?

502


Explain datetimeoffset data type in sal server 2008?

546


What are the types of sql server?

525


What is log ldf?

559


What is the security principal at the database level that represents your session?

548


How to write a query with a full outer join in ms sql server?

568


How to enable/disable indexes?

608


If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?

555


What triggers long term care?

565