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
What are the advantages to use stored procedures?
I have triggers,views,functions,stored Procedures for a table. When I am dropping that table which objects are deleted?
What do you mean by data integrity?
How to count duplicated values in a column in ms sql server?
Explain cursor as data base object?
You are doing log shipping due to some reasons it is failing. How you will proceed from there
Explain where clause?
What is update_statistics command?
What do you understand by user-defined function in the sql server and explain the steps to create and execute a user-defined function in the sql server?
What are extended events in sql server?
Can you explain different types of locks in sql server?
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
Are all views updatable ?
Which sql server is best?
How to create a view on an existing table in ms sql server?