Monday, August 10, 2026

168 ) 8) Department-Wise Sum of Salaries and Max Salary

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

8) Department-Wise Sum of Salaries and Max Salary

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Question:
Write a query to find the 
Department wise - 
total sum of salaries and the maximum salary for each department.

Query:

SELECT d.departmentname,
       Sum(e.salary) AS TotalDepartmentSalary,
       Max(e.salary) AS MaximumDepartmentSalary
FROM   employees e
       JOIN departments d
         ON e.departmentid = d.departmentid
GROUP  BY d.departmentname; 

 


DepartmentNameTotalDepartmentSalaryMaximumDepartmentSalary
IT4500012000
HR280009500

===========================

    No comments:

    Post a Comment

    173 ) 14 ) Query to find duplicate rows of loan id but time is different

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 )  Query to find duplicate rows of loan id but time is different  ~~~~~~~~~...