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.
How many gold medals did India win in the Asian Junior Boxing Championship 2021 in Dubai?
In which country the E-commerce and Technology conglomerate Alibaba located?
Which one of the following attributes is required for internal linking in HTML?
Which Article of the Constitution of India provides that ‘there shall be a Vice President of India’?
Which of the following events was conducted by the Ministry of Ayush, GoI to mark the 100-day countdown to the International Day of Yoga 2022?
Which of the following is true about respiration?
Who was the fourth President of India?
With which of the following companies has ISRO collaborated with to strengthen research and development of NaviC messaging service?
The writ by which a High Court or the Supreme Court can secure the body of a person who has been imprisoned to be brought before it is
Which of the following is correct?