|
发表于 2020-12-1 10:45:01
|
显示全部楼层
-- 你的题目没讲清楚,我在此也懒得去臆测,虽然下边这段代
-- 码也许不能给你答案,但可以给你一个思路.
declare @aa table (
aa int ,
bb int ,
cc char(8)
)
insert into @aa (aa , bb , cc)
select 1 , 255 , '20161212' union all
select 1 , 15 , '20161210' union all
select 2 , 33 , '20160612' union all
select 2 , 11 , '20160101'
--/进行删除操作以前,必须进行 select 操作,先看清楚要删的是否正确.
select *
from @aa a
where cc = (
select max(cc)
from @aa
where aa = a.aa
)
-- 经上一步确认无误后再执行下边一步,进行删除.
delete a
from @aa a
where cc = (
select max(cc)
from @aa
where aa = a.aa
)
-- 查看删除后的结果
select * from @aa |
|