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
What is NOT NULL Constraint in sql server 2012?
Define left outer join?
What is the most common type of join?
What are built in functions?
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?
What are relationships and mention different types of relationships in the dbms
Can sql server be linked with other servers like oracle?
what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration
When does a workload on SQL Azure get throttled?
What are the instances when triggers are appropriate?
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?
How sql server enhances scalability of the database system?
What is sql server schema compare? How we can compare two database schemas?
What is difference between clustered index and non clustered index?
What is autocommit mode in sql server?