首页 技术 正文
技术 2022年11月8日
0 收藏 535 点赞 1,983 浏览 2525 个字

w3resource_MySQL练习题:Aggregate_functions 1. Write a query to list the number of jobs available in the employees tableSample table: employees

-- 要点:count() + distinctselect count(distinct job_id)from employees

2. Write a query to get the total salaries payable to employees Sample table: employees

-- 要点:sum()select sum(salary)from employees

 3. Write a query to get the minimum salary from employees tableSample table: employees

-- 要点:min()select min(salary)from employees

4. Write a query to get the maximum salary of an employee working as a Programmer Sample table: employees

-- 要点:max()select max(salary)from employeeswhere job_id = 'IT_PROG'

  

5. Write a query to get the average salary and number of employees working the department 90Sample table: employees

-- 要点:avg() + count()select avg(salary), count(*)from employeeswhere department_id=90

6. Write a query to get the highest, lowest, sum, and average salary of all employees Sample table: employees

-- 要点:max() + min() + sum() + avg()select max(salary), min(salary), sum(salary), avg(salary)

  

7. Write a query to get the number of employees with the same jobSample table: employees

-- 要点:group by进行分组select job_id, count(*)from employeesgroup by job_id

8. Write a query to get the difference between the highest and lowest salaries Sample table: employees

-- 要点:max() + min()select max(salary)-min(salary)from employees

  

9. Write a query to find the manager ID and the salary of the lowest-paid employee for that managerSample table: employees

-- 要点:根据manager_id进行分组,得到每个分组内最低的salary(min)select manager_id, min(salary)from employeesgroup by manager_id

  

10. Write a query to get the department ID and the total salary payable in each departmentSample table: employees

-- 要点:根据department_id进行分组,得到每个分组内salary总和(sum)select department_id, sum(salary)from employeesgroup by department_id

  

11. Write a query to get the average salary for each job ID excluding programmerSample table: employees

-- 要点:通过job_id进行分组,得到每个分组内平均的salary(avg),select job_id, avg(salary)from employeeswhere job_id<>'IT_PROG'group by job_id

  

12. Write a query to get the total salary, maximum, minimum, average salary of employees (job ID wise), for department ID 90 onlySample table: employees

-- 要点:同上,通过job_id进行分组,得到每个组内相应数值,并且使用where进行department_id筛选select job_id, sum(salary), max(salary), min(salary), avg(salary)from employeeswhere department_id=90group by job_id

13. Write a query to get the job ID and maximum salary of the employees where maximum salary is greater than or equal to $4000 Sample table: employees

-- 要点:分组后的条件限制,使用havingselect job_id, max(salary)from employeesgroup by job_idhaving max(salary)>=4000

  

14. Write a query to get the average salary for all departments employing more than 10 employeesSample table: employees

-- 要点:同上,分组后使用havingselect department_id, avg(salary)from employeesgroup by department_idhaving count(salary)>10

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857