Question
What is the result of the following SQL query?
 SELECT department, COUNT (employee_id) FROM employees GROUPBY department HAVING COUNT (employee_id) > 5 ;Solution
Explanation: This query groups employee data by the department column and calculates the count of employees for each department using COUNT(employee_id) . The HAVING clause filters groups to include only those with a count greater than 5. The HAVING clause is specifically used for filtering after applying aggregate functions, unlike WHERE , which filters rows before aggregation. This query is commonly used in scenarios like resource allocation, workforce analysis, and performance reporting. Option A: The query does not display individual employee details, only aggregated department data. Option B: HAVING is valid with aggregate functions, provided it follows GROUP BY . Option D: This interpretation mixes individual and aggregated data, which is not possible here. Option E: The HAVING clause explicitly filters results, so this option is incorrect.
The ratio of length to breadth of a rectangle is 7:5. If the sum of the length and breadth of the rectangle is 48 cm, then find the area (cm2...
What is the process by which plants convert sunlight into chemical energy?
The speed of the stream is 10 km/h. Boat ‘A’ covers 60 km distance against the stream in 6 hours and boat ‘B’ covers 120 km distance against the...
Which accounting equation forms the basis of the balance sheet?
A tap can fill a tank in 6 hours. After half the tank is filled, three more similar taps are opened. What is the total time taken to fill the tank compl...
Which of the following statements about Preamble is correct?
According to the India State Forest Report 2021, which state has shown the highest increase in forest cover?
The sum of four consecutive integers is 170. Which one of these four Integers is prime?
Which of the following guidelines are correct for declaring a language as ‘Classical’?
-
High antiquity...
-
A man starts walking from his house towards the south. After walking 5 km, he turned to his left and walked 6 km. Then he walked further 5 km after turn...