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 following question , consists of an incomplete sentence or a sentence which is split into four parts. All four parts are jumbled up and are named a...
Which of the following is the third sentence of the passage?
Directions: Sentences of a paragraph are given below in jumbled order. Arrange the sentences in the correct order to form a meaningful and coherent par...
Which sentence should come fifth in the paragraph?
Which of the following is the fifth sentence in the passage?
Two years after it wrecked havoc in some delta districts , cyclone Gaja looms over the fate of candidates in nine assembly constituencies in the region....
Given below are a few sentences in which four words are emboldened each. The words may or may not be in their correct position. Rearrange the words if ...
Given below are six sentences, four of which (P, Q, R, S), are jumbled. Pick the option that gives the correct order of P, Q, R, S.
S - 1. The si...
The question consists of five statements labelled A, B, C, D and E which when logically ordered form a coherent passage. Choose the option that represe...
Given below are six sentences, four of which (P, Q. R, S), are jumbled. Pick the option that gives the correct order of P, Q, R, S.
S-1 A summary...