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 advantages of using third-party tools?

643


Do you know what is fill factor and pad index?

655


Define outer join?

623


How does a profiler work?

608


What is the purpose of floor function?

639






What is factless fact table? : sql server analysis services, ssas

658


Explain about Joins?

686


How do I determine how many instances of sql server are installed on a computer?

619


Explain what is the purpose of sql profiler in sql server?

635


How do you manipulate data?

586


How to assign null values to variables or columns?

633


Explain what is the function of sql server agent windows service?

631


how to trace the traffic hitting a sql server? : Sql server database administration

1273


What is the purpose of the model database?

671


What is a collation?

705