Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

--1.1. Find the highest, lowest, sum, and average salary of all employees.

Label the columns Maximum, Minimum, Sum, and Average, respectively. SELECT MAX(salary) AS "Maximum", MIN(salary) "Minimum ",sum(salary) "Sum " ,RO UND(AVG(salary),2) "Average" FROM employees; --1.2. Modify this query to display the minimum, maximum, sum, and average salar y for each job id. SELECT job_id,MAX(SALARY)AS "Maximum", MIN(salary) "Minimum ",sum(salary) "Sum " ,ROUND(AVG(salary),2) "Average" FROM employees GROUP BY Job_Id ; --2.1Write a SQL query to display the number of people with the same job. SELECT job_id,COUNT(employee_id) "No.of Employees" FROM Employees GROUP BY Job_Id ; --3.1 Determine the number of managers without listing them. Label the column Nu mber of Managers. SELECT manager_Id,COUNT(manager_id) "Number of Managers" FROM Employees GROUP BY manager_Id ; SELECT COUNT(DISTINCT manager_id) "Number of Managers" FROM employees; --4.1Find the difference between the highest and lowest salaries. Label the colu mn DIFFERENCE. SELECT MAX(salary) AS "HIGHEST", MIN(salary) "LOWEST", MAX(salary) - MIN(salary ) "DIFFERENCE" FROM employees; --5.1Create a report to display the manager number and the salary of the lowestpaid employee for that manager. --Exclude anyone whose manager is not known. Exclude any groups where the minimu m salary is $6,000 or less. --Sort the output in descending order of salary. SELECT manager_id AS " Manager_Id ", MIN(salary) AS "Minimum" FROM employees WHERE manager_id IS NOT NULL GROUP BY manager_id HAVING MIN(salary) > 6000 ORDER BY MIN(salary) DESC;

You might also like