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 / grace

SELECT A.*
FROM dbo.T1 A
WHERE CustomerID IN
(SELECT TOP 10 CustomerID FROM dbo.T1 WHERE City=A.City)

Is This Answer Correct ?    24 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is change data capture (cdc) feature?

602


What is the difference between locking and multi-versioning?

542


Can we insert data into view sql server?

522


What are scalar functions in sql?

617


What is outer join in sql server joins?

604






How to list all objects in a given schema?

575


explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

603


How do I view a stored procedure in sql server?

524


What does it mean to normalize a database and why would you do it?

542


What is partition in sql server?

543


What are the steps you will take to improve the performance of a poor performing query?

609


How much does sql server 2016 cost?

544


Can we take the full database backup in log shipping?

548


What is merge replication?

716


What is the use of custom fields in report?

570