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 NOT NULL Constraint in sql server 2012?

751


Define left outer join?

756


What is the most common type of join?

726


What are built in functions?

756


While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?

782






What are relationships and mention different types of relationships in the dbms

741


Can sql server be linked with other servers like oracle?

700


what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration

721


When does a workload on SQL Azure get throttled?

127


What are the instances when triggers are appropriate?

719


As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?

806


How sql server enhances scalability of the database system?

778


What is sql server schema compare? How we can compare two database schemas?

768


What is difference between clustered index and non clustered index?

796


What is autocommit mode in sql server?

708