如何用SQL语句去筛选出来,并删除。

[复制链接]
查看11 | 回复5 | 2009-7-14 13:58:04 | 显示全部楼层 |阅读模式
--表名改一下,有2个地方。保留salary最大的一个delete from 表 awhere not exists(
select * from (
select emp_name,max(salary) salary
from 表 group by emp_name
) b
where a.emp_name=b.emp_name and a.salary=b.salary...
回复

使用道具 举报

千问 | 2009-7-14 13:58:04 | 显示全部楼层
delete from emp where enp_id in(select min(emp_id) from emp group by emp_name)...
回复

使用道具 举报

千问 | 2009-7-14 13:58:04 | 显示全部楼层
select name,min(salary) from table group by name...
回复

使用道具 举报

千问 | 2009-7-14 13:58:04 | 显示全部楼层
delete from 表 where EMP_ID in (select top 1 EMP_ID from 表 where EMP_NAME = 'sunshine' , select top 1 EMP_ID from 表 where EMP_NAME = 'semon')...
回复

使用道具 举报

千问 | 2009-7-14 13:58:04 | 显示全部楼层
delete from emp where enp_id in(select min(emp_id) from emp group by emp_name)...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行