首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

急求一sql句子!解决办法

2012-03-01 
急求一sql句子!例如表aa:aabbcc125520061212115200612102332006061221120060101按cc用DESC排序了,如我想删

急求一sql句子!
例如表aa:
aa         bb           cc
1             255         20061212
1             15           20061210
2             33           20060612
2               11           20060101
按cc用DESC排序了,
如我想删除where   aa= '2 'or   其他中处的最近时间资料.
结果表aa:
aa         bb           cc
1             255         20061212
2             33           20060612

谢谢!


[解决办法]
create table tt
(
aa int ,
bb int ,
cc varchar(08)
)
insert into tt
select 1, 255 , '20061212 ' union
select 1, 15 , '20061210 ' union
select 2, 33 , '20060612 ' union
select 2, 11 , '20060101 '

select a.*
from tt a
where not exists
(select 1 from tt where aa = a.aa and cc > a.cc)
[解决办法]
delete from t where aa=2 and cc in (select max (cc) from t where aa =2)
select * from t
[解决办法]
http://community.csdn.net/Expert/topic/5275/5275251.xml?temp=.1500818

帮我看看哈.

热点排行