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

Tell me extended events in sql server 2008?

565


Do you know exporting and importing utility?

539


Explain system rowset functions?

561


How to list all login names on the ms sql server?

538


Explain view in sql server?

626






What is rolap and its advantage? : sql server analysis services, ssas

648


Explain the usage of floor function in sql server.

508


what exactly sql injuction.how to overcome.....

2043


What is subquery in sql?

573


What is sqlcmd?

559


What is an index in sql?

555


Can foreign key be deleted?

532


Can we check locks in database? If so, how can we do this lock check?

532


What are different backups available in sql server?

612


Difference between DELETE and TRUNCATE?

617