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 are the advantages of using stored procedures?

687


What is a full text index?

669


How to create an identity column?

850


What is the sql server agent?

786


Can I use sql azure as a backup with log shipping or database mirroring?

148






What are the extra roles available in msdb? : sql server security

848


How to drop an existing table?

726


What is autocommit mode in sql server?

710


What is a DBMS, query, SQL?

773


What are trace files?

707


How to get @@error and @@rowcount at the same time?

775


Explain sql delete command?

792


Can we use where clause with group by?

672


What is the difference between char and varchar2 datatype in sql?

744


What are two difference between sql azure and azure tables?

153