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.
Pipes 'G' and 'H' can fill a tank in 24 hours and 8 hours respectively, while pipe 'I' can empty it in 48 hours. All pipes are opened together when the ...
Pipe A and Pipe B together can fill the tank in 15 hours. The capacity of the pipe A is 20% of the capacity of the pipe B. How much time will pipe B alo...
Pipe ‘P’ and pipe ‘Q’ together can fill an empty tank in 18 hours while pipe ‘Q’ and pipe ‘R’ together take 12 hours to fill the same ta...
Pipe ‘A’ can fill a tank in 40 hours whereas leak ‘A’ can empty it in 50 hours. If they both operate along with pipe ‘B’, then the given tan...
If a tank can be filled by a tap in 20 hours, but due to an outlet, it actually takes 8 hours longer to fill the tank, find the duration in which the ou...
Two inlets X, Y fill the tank in 18 and 9 minutes. Outlet Z is 50% less efficient than X. ‘X’ and ‘Z’ open for 6 minutes, then X is replaced wit...
Two pipes, X and Y, can individually fill a tank in 50 minutes and 25 minutes respectively. If both pipes are opened simultaneously, after how much time...
- Pipes ‘D’ and ‘E’ alone can fill a tank in 16 minutes and 24 minutes, respectively, while pipe ‘F’ can empty the same tank in 48 minutes. If al...
A tank is filled by 3 pipes, second pipe take 5 hours more than first pipe and 5 hours less than third pipe to fill the tank alone. If second and third ...
Pipe A fills a tank in 60 minutes, and pipe B can do it in 90 minutes. There’s also a pipe C that drains the tank in 180 minutes. If all three pipes a...