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


Please Help Members By Posting Answers For Below Questions

What is bcp? When does it used?

739


Explain about sql server login?

794


What are sql dirty pages?

768


What extended events?

783


what's the information that can be stored inside a bit column? : Sql server database administration

744


What is use of except clause? How it differs from not in clause?

773


Which tcp/ip port does the sql server run on? How can it be changed?

741


What is transaction server consistency?

740


Why do we backup Active Directory ?

812


What are “unrepeatable reads”?

951


query processing

1931


What is the difference between seek predicate and predicate?

774


Explain trigger and its types?

822


Explain “@@rowcount” and “@@error” in sql server?

740


Does windows server 2016 come with sql server?

694