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

[打卡]单行子查询

2024-05-14 15:14:16
0
143

SELECT * from employees where salary>(
SELECT salary
from employees
where employee_id=149
);



select last_name,job_id,salary from employees
WHERE job_id=(
select job_id from employees where
employee_id=141
)
and salary>(
SELECT salary
from employees
where employee_id=143

) ;

SELECT last_name,job_id,salary
from employees
where salary=(
select min(salary)
FROM employees
);
#法1
select employee_id,manager_id,department_id
from employees
where manager_id=(
SELECT manager_id
FROM employees
where employee_id=141
)
and department_id=(

SELECT department_id
FROM employees
where employee_id=141
)and employee_id !=141;
#法2
select employee_id,manager_id,department_id
from employees
where (manager_id,department_id)=(
SELECT manager_id,department_id
FROM employees
where employee_id=141
) and employee_id !=141;


#聚合函数参与运算删选条件用having
SELECT department_id,min(salary)
FROM employees
where department_id is not null
GROUP BY
HAVING min(salary)>(
SELECT min(salary)
from employees
WHERE department_id=110

);


select employee_id ,last_name
from employees
where salary=(
select min (salary)
from employees
GROUP BY department_id

);































评论
意见反馈