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 is PROJECTION Operation?

609


How to change the ownership of a schema in ms sql server?

563


Explain logical operators in sql server?

569


What is the significance of null value and why should we avoid permitting null values?

530


What is a fill factor?

624






If user is owning any SQL Objects, can we drop that user

1602


How can sql injection be stopped? : sql server security

550


Explain a checkpoint?

536


Explain temporary table vs table variable by using cursor alternative?

517


What are statistics?

570


What is plan freezing?

584


Benefits of Stored Procedures?

565


Explain what are various ways to enhance the ssrs report?

570


What is a trace frag?

641


How to drop an existing stored procedure in ms sql server?

542