Start learning 50% faster. Sign in now
To calculate the average salary of employees in each department, we need to use the AVG() aggregate function in SQL. The GROUP BY clause is essential here, as it groups the results by department, ensuring the average is calculated for each individual department, not for the entire table. The correct SQL query is: SELECT department, AVG(salary) FROM employees GROUP BY department This query returns the department and the average salary of employees in that department. Why other options are wrong: b) SELECT department, SUM(salary) FROM employees GROUP BY department : This calculates the sum of the salary, not the average. It’s useful when you want the total salary for each department. c) SELECT department, AVG(salary) FROM employees : This query is incomplete because it lacks the GROUP BY clause. Without it, it would give the average salary for the entire table, not by department. d) SELECT AVG(salary) FROM employees GROUP BY department : This query incorrectly places the aggregate function without selecting the department column, which will result in an error or incorrect output. e) SELECT department, COUNT(salary) FROM employees GROUP BY department : This counts the number of salaries in each department, not the average salary.
A sentence is given in which certain words are highlighted. Choose the option with the pair/s of words that need to be interchanged to make the sentence...
In the question below, a sentence is given with four words highlighted in bold, followed by options that provide a replacement for each word. From the o...
In the following sentence four words are given in bold. They may or may not be in the correct position in the sentence. You have to find out which two...
In the question given below, four words are given in bold. These four words may or may not be in their correct position. The sentence is then followed...
Directions : In each of the questions given below, four words are given in bold. These four words may or may not be in their correct position. The se...
In the questions given below, four words are given in bold. These four words may or may not be in their correct position. The sentence is then followed ...
In the given question, four words are printed in bold and numbered A, B, C, and D. The positions of some highlighted words may be incorrect and need to...
In the following sentences four words are given in bold. They may or may not be in the correct position in the sentence. You have to find out which two...
Directions : In each of the questions given below, four words are given in bold. These four words may or may not be in their correct position. The se...
Directions: Two sentences are given in the question below. Three words are emboldened in each of the sentences. Interchange the words to make meaningful...