1,在未知表table 中查询第n行数据2,学生表 如下:
自动编号 学号 姓名 课程编号 课程名称 分数
1 2005001 张三 0001 数学 69
2 2005002 李四 0001 数学 89
3 2005001 张三 0001 数学 69
删除除了自动编号不同,其它都相同的学生冗余信息
自动编号 学号 姓名 课程编号 课程名称 分数
1 2005001 张三 0001 数学 69
2 2005002 李四 0001 数学 89
3 2005001 张三 0001 数学 69
删除除了自动编号不同,其它都相同的学生冗余信息
2.delete from table where 自动编号 not in(select max(自动编号)自动编号
from table group by 学号 ,姓名 ,课程编号, 课程名称 ,分数)
select * from # where px=n2 delete A from A b where exists( select 1 from A where 学号=b.学号 and 姓名=姓名.姓名 and 课程编号=b.课程编号 and 课程名称=b.课程名称 and 分数=b.分数 and 自动编号>b.自动编号)
delete A from A b where exists( select 1 from A where 学号=b.学号 and 姓名=b.姓名 and 课程编号=b.课程编号 and 课程名称=b.课程名称 and 分数=b.分数 and 自动编号>b.自动编号)
select * from
(
select px=row_number() over (order by id ), * from A
) a
where px=n2 delete A from A b where id not in ( select id from A where 学号=b.学号 and 姓名=姓名.姓名 and 课程编号=b.课程编号 and 课程名称=b.课程名称 and 分数=b.分数)
2.delete from table where 自动编号 not in(select max(自动编号)自动编号
from table group by 学号 ,姓名 ,课程编号, 课程名称 ,分数)