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.
India’s first 'coal to methanol' (CTM) plant is built by which of the following?
With reference to the Blue economy, consider the following statements:
1. Blue economy refers to the sustainable use of marine resources for expl...
Which country is hosting the 20th Asian Women’s Handball Championship in December 2024?
The PM-SURAJ Portal, a recently launched initiative aimed at promoting transparency and accountability in governance, has been implemented by which mini...
Who is featured from Bollywood in TIME's 100 Most Influential People in AI list?
Which entity has introduced the ABSLI Nishchit Aayush Plan?
Which countries will host the FIFA World Cup in 2030?
“ EX VINBAX 2022” military exercise takes place between?
What was the main objective of the Global Initiative on Digital Health launched by India and WHO at the G-20 summit in Gandhinagar?
According to a report by CBRE, what is the projected number of new senior living facilities in India in the next 10 years?