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 an expression in ms sql server?

571


What is difference between joins and subqueries?

538


What command do we use to rename a db, a table and a column?

506


How do indexes help, types?

554


How to remove duplicate rows from table?

603






What are the differences between char and varchar in ms sql server?

579


What is normalization? What number of normalization shapes are there?

606


What is Command line parameters in PLSQL.?

584


What is the maximum size of column in sql server?

509


What is indexing and its types?

531


What is the meaning of resultset type_scroll_insensitive?

565


Which tcl commands are available on the sql server?

607


What is application role in sql server database security? : sql server security

556


In what three ways is the return statement used in a stored procedure?

514


Do you know what is difference between index seek vs. Index scan?

522