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
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?
Can we add our custom code in ssis?
What authentication modes does sql server support?
What is an inner join?
how many bits ip address consist of? : Sql server database administration
What are indexes in ms sql server?
How many types of objects are there?
What is the use of keyword with encryption.
Why union all is faster than union?
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?
What is a data collection table?
Difference between Inner vs outer joins?
Define constraints and give an example of their use?
What is a partitioned view?
what are the Prerequisites for Replication?