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.
Rocket works on the principle of which one of the following?
In Ball Badminton, players change the ends in each game when a side first scores all of the following, EXCEPT:
The directions of Reserve Bank of India (Unhedged Foreign Currency Exposure) shall come into effect from ______.
What is the Bihar Literacy Rate at present?
Who built the Sanchi Stupa?
Plants that do not have well-differentiated body design fall in this group. The plants in this group are commonly called algae. These plants are predomi...
Name the Punjabi Muslim, who was a student at Cambridge and who coined the term 'Pak-Stan" in 1933?
Arrange the following cricket players in descending order as per the most runs taken by them during IPL 2020.
A. KL RahuL
B. Shikhar...
Which of the following is an auxiliary river of the Ganges originates from the high peninsular land?
What is the name of the one-stop mentorship platform launched by Startup India to facilitate mentorship for startups across various sectors, stages, and...