Grouped query - Summary Practice

1 . Job_id query maximum value of an employee's salary, minimum, average, sum, press job_id ascending 

SELECT max (the salary), min (the salary), AVG (the salary), SUM (the salary), job_id from the Employees 
Group by job_id 
the Order by job_id;
2 query highest wage gap between employees and the minimum wage of 

the SELECT max (salary) -min (salary) -difference from the Employees;
3 . Queries minimum wage employees of each manager's hands, where the minimum wage can not be less than 6000, no management staff do not count 

the SELECT   min (salary), manager_id
 from the Employees
 the WHERE manager_id IS not null 
Group by manager_id 
the HAVING min ( the salary) > = 6000 ;
4 . All inquiries department number, the number of employees and the average wage, according to the average company Descending 

the SELECT department_id, COUNT (* ), AVG (salary) AVG
 from the Employees 
Group by department_id 
the Order by AVG desc;
5 . The number of employees select each job_id 

SELECT COUNT (* ), job_id
 from the Employees 
Group by job_id;

 

Guess you like

Origin www.cnblogs.com/Jasmine6-Lee/p/12654764.html