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 and B started a business by investing Rs.500 and Rs.600 respectively. After 8 months, A increased his investment by Rs.700. Find the ratio of annual p...
A and B invest in a business in the ratio 3:5. After 8 months B leaves the business after withdrawing his investment. In the first year the business mad...
P started a business with an investment of Rs.9000, after 6 months Q joined him with Rs.12000 and after another 6 months R joined them with Rs.15000. If...
If a sum of money is to be divided among A, B, C such that A’s share is equal to twice B’s share and B’s share is 5 times C’s share then their s...
How much a sum was put at fixed rate of simple interest for 5 years. If the interest would have been 6 % higher than the foregoing rate, then Rs. 7500 w...
P and Q started a business by investing Rs.5000 and Rs.3000 respectively. After 4 months, Q increased his investment by a certain percentage such that a...
A sum of ₹4,360 was to be divided among A, B, C, and D in the ratio 3:4:5:8, but it was divided in the ratio 1/3:1/4:1/5:1/8. Was divided by mistake: ...
Three persons Arvind, Bittu and Chinmey entered into a partnership with initial capitals of Rs.5000, Rs.7000, Rs.9000 respectively for 6 months, 5 month...
Three partners, X, Y, and Z, invest Rs 24,000, Rs 30,000, and Rs 36,000 respectively in a business. The total profit after one year is Rs 48,000. If par...
A sum of ₹5000 is to be distributed among A, B, and C. A receives 2 times the amount received by B, and B receives 3 times the amount received by C. F...