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 does the automatic recovery do?

579


What is single-user mode and what are the steps you should follow to start sql server in single-user mode?

559


Explain go command in sql server?

548


whats new about truncate in sql server 2008?

2030


What specific conditions database should meet, before you can bulk copy data into it using bcp?

540






How to end a stored procedure properly in ms sql server?

550


If the job running very slow what is the action you do

1428


What is sub query and its properties?

549


What are the different types of data sources in ssrs?

142


How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?

1633


List the different normalization forms?

546


What is de-normalization in sql database administration? Give examples?

540


What will be the maximum number of index per table?

592


What is a deadlock and what is a live lock?

580


What does it mean to manipulate data?

568