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
Can truncate be rolled back?
Write a query for primary key constraint with identity key word?
How many types of subqueries are there in sql server?
What are clustered and non-clustered index?
Where is my database stored on the hard disk in ms sql server?
What is a document index?
Why is normalisation important?
Determine when to use stored procedure to complete sql server tasks?
What command is used to delete a table from the database in the sql server and how?
What is trigger explain with program?
How to create an inline table-valued function?
What are different types of statement?
What are constraints in microsoft sql server?
What is full outer join in sql server joins?
What is a transaction and why is it important?