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 / asim

select id,addressid,city
from
(
SELECT ROW_NUMBER() OVER (partition by city Order by
addressid) ID,AddressID,City
FROM person.Address A
WHERE City IN
(select city from person.address group by City

) )a
where a.ID <11
order by City,ID

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the system database in sql server 2008?

571


Please explain go command in sql server?

583


how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration

570


What is query optimization process?

512


List the ways in which dynamic sql can be executed?

630






What is a performance monitor?

548


How you would rewrite the sql query to return the customerid sorted numerically?

568


Mention the differences between having and where clause.

546


How to list all stored procedures in the current database using ms sql server?

628


How does index makes search faster?

591


Can foreign key be deleted?

519


What are the types of indexes?

585


Explain something about security and SQL Azure?

88


Why do you want to join software field as you have done your BE in Electronics?

1694


What is user-defined scalar function?

548