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
What is bcp? When does it used?
Explain about sql server login?
What are sql dirty pages?
What extended events?
what's the information that can be stored inside a bit column? : Sql server database administration
What is use of except clause? How it differs from not in clause?
Which tcp/ip port does the sql server run on? How can it be changed?
What is transaction server consistency?
Why do we backup Active Directory ?
What are “unrepeatable reads”?
query processing
What is the difference between seek predicate and predicate?
Explain trigger and its types?
Explain “@@rowcount” and “@@error” in sql server?
Does windows server 2016 come with sql server?