can any one answer this query,thank you in advance

Table 1 has 2 columns: EmployeeId, T shirtsize(values can
be 1,2,3)
Table 2 has 2 columns: EmployeeId, Region
Write SQL to Find the region which has the largest number
of people with Tshirt size=3

Answer Posted / lakram5455

SELECT a.Region FROM
(SELECT TOP(1) a.TSize, COUNT(a.EId) AS TotalCount, b.Region
FROM emp a INNER JOIN Region b ON b.EId = a.EId WHERE TSize
= 3 GROUP BY a.TSize, b.Region ORDER BY TotalCount DESC) a

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is PROJECTION Operation?

683


Can a stored procedure call itself or a recursive stored procedure? How many levels of sp nesting is possible?

664


Explain Geography datatype in SQL Server

708


What are views in ms sql server?

682


Do you know sql server 2008 introduces automatic auditing?

601






How can we determine what objects a user-defined function depends upon?

593


Write an SQL query to obtain the 2nd highest salary.

689


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?

626


What is the rdl file?

96


What are group functions in query statements in ms sql server?

637


What are the Advantages of using CTE in sql server?

656


What are the steps to take to improve performance of a poor performing query? : sql server database administration

689


Write a program to fetch first 10 records from a file?

676


How to insert multiple rows with one insert statement in ms sql server?

678


Why should one not prefix user stored procedures with ‘sp_’?

695