留言板网站怎么做,廊坊公司快速建站,中国做民宿的网站,泉州百度竞价推广1从不订购的客户 分析#xff1a;从不订购#xff0c;就是购买订单没有记录#xff0c;not in
我的代码#xff1a;
select c.name as Customers
from Customers c
where c.id not in (select o.customerId from Orders o)
2 部门工资最高的员工 分析#xff1a;每个部…1从不订购的客户 分析从不订购就是购买订单没有记录not in
我的代码
select c.name as Customers
from Customers c
where c.id not in (select o.customerId from Orders o)
2 部门工资最高的员工 分析每个部门group by薪资最高排序取第一 or max函数员工
我的错误代码
select d.name Department ,e.name Employee ,e.salary Salary
from Employee e join Department d on e.departmentId d.id
group by d.id
order by e.salary
正确代码按照(部门id和最大薪资)进行查询这样才能保证找出同部门可能存在的多个最高薪资的员工。
select d.name Department ,e.name Employee ,e.salary Salary
from Employee e join Department d on e.departmentId d.id
where (e.departmentId,e.salary) in #找每个部门最高薪资的可能不止一个
(select departmentId,max(salary) from Employee
group by departmentId) 3 删除重复的电子邮箱 分析重复的好找如何删除select——delete
我的代码delete不会用 第一次好像是delete中不能用分组函数group by?
delete id,email
from Person
group by id
having count(email)1 为什么这样也不行呢
delete from Person
where id in
(select id
from Person
group by id
having count(email)1)
官方答案from后调用自身表两次email相等但是重复的前面id不等不等则删掉
delete p1
FROM Person p1,Person p2
WHEREp1.Email p2.Email AND p1.Id p2.Id好了好了不卷了