Question
Which SQL query would return the top three departments
with the highest total salaries from an employees table with columns department , salary , and employee_id ?Solution
Explanation: The correct query uses SQL’s GROUP BY to aggregate data by department , calculates the sum of salary for each department using SUM(salary) , and orders the results in descending order with ORDER BY . Finally, the LIMIT 3 clause retrieves only the top three departments. This approach is efficient and aligns with database query standards, ensuring the highest salaries are calculated accurately and in rank order. Option B: MAX(salary) cannot be used without a GROUP BY clause for the entire table, and the syntax is incorrect. Option C: COUNT(salary) measures frequency, not total salary. Option D: DISTINCT eliminates duplicates but does not aggregate data for rankings. Option E: MAX(salary) sorts by individual highest salaries, not aggregated totals, leading to incorrect results.
The difference between the present ages of a mother and her son is 32 years. Six years ago, the mother was 4 years younger than twice the present age of...
A petrol pump has a blend of 40 liters of petrol and diesel in the ratio of 5:3. After selling 16 liters of the mixture, 12 liters of petrol are added t...
In what ratio rice at 44 Rs/kg should be mixed with the rice at 28 Rs/kg so that selling mixture at Rs 42 per kg gives the profit of 20% if the quantity...
A merchant initially sells wheat with a 25% profit margin. However, if the selling price is lowered by Rs. 40, the sale results in a 25% loss instead. W...
In what ratio rice at 48 Rs/kg should be mixed with the rice at 34 Rs/kg so that selling mixture at Rs 46 per kg gives the profit of 15% if the quantity...
4, 14, 44, 134, ?, 1214
9 litre of milk is taken out from a container and replaced by water. This process is repeated once more, the ratio of quantity in container (M: W) is 16...
What will come in the place of question mark (?) in the given expression?
(18.75% of 800 ÷ 5) of 40 ÷ 10 = ?
In what ratio coffee at 275 Rs/kg should be mixed with the coffee at 325 Rs/kg so that after mixture its rate become 290 Rs/kg if the quantity of 1st ty...
In a zoo, tiger and ostrich were counted. If heads were counted, there are 400 and if legs are counted there were 820. How many ostrich are there?