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
What are the events recorded in a transaction log?
What is the difference between varchar and varchar types?
What are the kinds of subquery?
in the physical file layout, where should the transaction log be stored in relation to the data file?
What is the command to change the recovery model?
What is Service Broker in sql server 2012?
How do you delete duplicate records in sql server?
What are the differences between sql server and mysql.
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?
How do I port a number to sql server?
What xml support does the sql server extend?
What is the federation in sql azure?
How to execute stored procedure in select statement sql server?
What are the disadvantages of using the stored procedures?
In case you have filters in your report, when filters will be applied in cached report instance?