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 / abhijith

select top 10 *
from tablename
where city IN
(select distinct(city) from tablename)

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?

2014


Can we add our custom code in ssis?

549


What authentication modes does sql server support?

599


What is an inner join?

527


how many bits ip address consist of? : Sql server database administration

458






What are indexes in ms sql server?

551


How many types of objects are there?

505


What is the use of keyword with encryption.

578


Why union all is faster than union?

508


You want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition?

538


What is a data collection table?

540


Difference between Inner vs outer joins?

534


Define constraints and give an example of their use?

561


What is a partitioned view?

569


what are the Prerequisites for Replication?

10570