
Answer-first summary for fast verification
Answer: SELECT Department, AVG(Salary) AS AverageSalary FROM EmployeeData GROUP BY Department;
Option A is the correct choice because it efficiently uses the AVG() function to calculate the average salary for each department and groups the data by department, which is a best practice for performance and scalability. This approach ensures that the query is optimized for large datasets and future growth, aligning with the requirements of being cost-effective and scalable. Options B and D, while they may produce the correct result, are less efficient because they manually calculate the average, which can be more resource-intensive. Option C does not group the data by department, leading to incorrect results.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You are working as a Fabric Analytics Engineer and have been given a task to analyze employee data stored in a Fabric lakehouse. The dataset includes employee details such as department, salary, and years of experience. Your manager has asked you to provide a report that shows the average salary for each department, ensuring the solution is cost-effective and scalable for future data growth. Which of the following SQL queries would you use to accurately retrieve the average salary for each department, along with the department name, while also considering best practices for performance and scalability? (Choose one correct answer)
A
SELECT Department, AVG(Salary) AS AverageSalary FROM EmployeeData GROUP BY Department;
B
SELECT Department, SUM(Salary) / COUNT(*) AS AverageSalary FROM EmployeeData GROUP BY Department;
C
SELECT Department, AVG(Salary) AS AverageSalary FROM EmployeeData ORDER BY Department;
D
SELECT Department, SUM(Salary) / COUNT(Department) AS AverageSalary FROM EmployeeData GROUP BY Department;