首页 小组 文章 相册 留言本 用户 搜索 我的社区 在线学堂 商城 购物车 支付钱包

[打卡]聚合函数—陈天宇

2024-04-26 12:16:27
0
123

# COUNT

# 作用:计算指定字段在查询结果中出现的个数

SELECT COUNT(employee_id),COUNT(salary),COUNT(salary*12)
FROM employees;

SELECT COUNT(1)
FROM employees;

SELECT COUNT(4)
FROM employees;

SELECT COUNT(*)
FROM employees;

SELECT COUNT(commission_pct)
FROM employees;

SELECT commission_pct
FROM employees
WHERE commission_pct IS NOT NULL;

SELECT AVG(salary),SUM(salary)/COUNT(salary),
AVG(commission_pct),SUM(commission_pct)/COUNT(commission_pct),
SUM(commission_pct)/107
FROM employees;

SELECT AVG(commission_pct)
FROM employees;

SELECT SUM(commission_pct)/COUNT(1)
FROM employees;

SELECT department_id,AVG(salary),MAX(salary)
FROM employees
GROUP BY department_id;

SELECT job_id,AVG(salary)
FROM employees
GROUP BY job_id;

SELECT department_id,job_id,AVG(salary)
FROM employees
GROUP BY department_id,job_id;

SELECT department_id,job_id,AVG(salary)
FROM employees
GROUP BY job_id,department_id;

#错误
SELECT department_id,job_id,AVG(salary)
FROM employees
GROUP BY department_id;


评论
意见反馈