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 the command dbcc checkdb used for?

513


What is the difference between seek predicate and predicate?

564


What is log shipping?

543


what are isolation levels? : Sql server database administration

477


What is ssl in sql server?

529






Explain different forms of normalization?

509


What is enhanced database mirroring in sql server 2008?

496


hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.

2446


What is oltp (online transaction processing)?

561


Explain relational data?

521


What do you understand by recursive stored procedure?

504


What is a mutating table error and how can you get around it?

517


What is unpivot?

549


Do you know how to implement service broker?

516


Can we store videos inside the sql server table?

500