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 / sitaram karancheti
In Oracle:
SELECT COUNT(table1.emp_id), region
FROM table1, table2
WHERE tshirt_size = 3 AND table1.emp_id = Table2.emp_id
AND rownum < 2
GROUP BY region
ORDER BY COUNT(table1.emp_id) DESC
In MySql:
SELECT COUNT(table1.emp_id), region
FROM table1, table2
WHERE tshirt_size = 3 AND table1.emp_id = Table2.emp_id
GROUP BY region
ORDER BY COUNT(table1.emp_id) DESC LIMIT 1
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
How to find which stored procedure is currently running in sql server?
Can you create a logon trigger in sql server 2005 express edition?
Does windows server 2016 come with sql server?
Do you know what is replace and stuff function in sql server?
How can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role?
How to execute function in stored procedure sql server?
What is the difference between value type and reference type?
What is the recursive stored procedure in sql server?
What is the difference between implicit and explicit transaction?
What are the types of resultset?
What does ss stand for sexually?
Do you know query execution plan?
What is built-in/administrator?
Why use sub query in sql server and list out types of sub queries?
Explain tables in SQL Azure?