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
How many types of subqueries are there in sql server?
What is Sqlpaging in SqlServer 2005 ?
What is the use of partition by in sql server?
What is an identity?
What does the update command do?
How can I add Reporting Services reports to my application?
What is the synonym of join?
Do you know the cursor optimization tips?
what purpose does the model database serve? : Sql server database administration
What is trace flag in sql server?
What is transaction server auto commit?
IF more than one Site is accessing the same Database server and I want to move the DB with Minimum down time? How will you do
Does group by or order by come first?
How to create sub reports?
What are the rendering extensions of ssrs?