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 / rakesh ameta

create table newq(ids numeric(5),sname nvarchar(10),city nvarchar(10))

select * from newq where newq.ids in(select top 10 ids from newq x where newq.city=x.city)

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is resource db in sql server?

598


What is data modeling and Reterminal integrity?

1494


hi i am working as a testengineer , so i want to no the backend data base connection can any one tell mwe in detail

1788


Define candidate key, alternate key, and composite key.

536


Can you explain different types of joins?

547






How do I view a procedure in sql server?

540


What is pessimistic concurrency?

542


Explain trigger and its types?

614


What are click through reports?

99


How to write a query with a right outer join in ms sql server?

480


How do I open a .db file?

482


How can I tell if sql server is 32 or 64 bit?

501


What are the drawbacks of reporting in ssrs?

108


How you can minimize the deadlock situation?

555


We need to perform what steps in the following order to work with a cursor?

712