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.
Indian Railways has issued the Letter of Award (LoA) for Manufacturing and Maintenance of 9000 HP Electric Freight Locomotives to ____.
Who was honored at the National Fame Awards 2024 for exceptional contributions in their field?
Which company constructed India's first 3D-printed post office in Cambridge Layout, Bangalore, with technical guidance from IIT Madras, and completed th...
Who is the youngest batsman to hit double centuries in one-day international cricket?
What budget has India projected annually until 2030 for biodiversity initiatives as part of the updated NBSAP?
Recently England’s Leicester Cricket Ground has been named after India's legendary cricketer_____?
E-crop, a crop simulation model-based device, was developed by which one of the following institutes?
Recently Lillemor Koper won Gold medal in 2022 ICF Canoe Sprint World Championships . She is from which country?
Mrs Preeti Sudan is the new member appointed by which of these organizations recently?
Which Indian state has recently signed a MoU with the National Tiger Conservation Authority (NTCA) to establish its first Special Tiger Protection Force...