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 longest River in the Peninsular India is
There was a prescribed aim under the National Population Policy, 2000, that a stability will be achieved in population by the year 2045 Now the target y...
In which Raising Day Parade did Union Minister Ashwini Vaishnaw participate in Nashik?
In which state is the ‘Anpara Thermal Power Station’ located?
HSN code stands for Harmonised______ of Nomenclature code.
When was the Pradhan Mantri Awas Yojna (Gramin) launched?
What is the currency of the Maldives?
According to the NABARD Rural Financial Inclusion Survey 2021-22, what percentage of an agricultural household’s income in India comes from cultivatio...
Name the commodity exchange which recently launched India's first agri-commodity options in gaur seed
A, B is longer than C, but C is not as long as D. E, F is longer than D but not as long as B. E, F is longer than C. Which of the following is the longest?