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

[打卡]重生 之 我的mysql 欢乐多

2024-04-23 12:16:41
0
193

SELECT last_name,e.department_id,
department_name
FROM employees e
LEFT OUTER JOIN departments d
ON e.department_id=d.department_id;

SELECT job_id, location_id
FROM employees e
JOIN departments d
ON e.department_id = d.department_id
WHERE e.department_id = 90;

SELECT last_name , job_id , e.department_id , department_name
FROM employees e, departments d, locations l
WHERE e.department_id = d.department_id
AND d.location_id = l.location_id
AND city = 'Toronto';

SELECT department_name, street_address, last_name, job_id, salary
FROM employees e JOIN departments d
ON e.department_id = d.department_id
JOIN locations l
ON d.`location_id` = l.location_id
WHERE department_name = 'Executive'

SELECT employee_id,last_name,department_name
FROM employees e,departments d
WHERE e.department_id = d.`department_id`
AND d.`department_name` IN ('Sales','IT');

#第七章聚合函数
#1 常见的聚合函数
#1.1 AVG / SUM 只适用于数值类型的字段(或变量)

SELECT AVG(salary),SUM(salary)
FROM employees;

SELECT AVG(last_name),SUM(last_name),AVG(hire_date),SUM(hire_date)
FROM employees;


#1.2 MAX / MIN 适用于数值类型、字符串类型、日期时间类型的字段
SELECT MAX(salary),MIN(salary)
FROM employees;

评论
意见反馈