Sql语句问题??

来源:百度知道 编辑:UC知道 时间:2024/06/07 16:47:26
分组后,在组内按时间排序提取前两条,其他删除。数据库字段是 newstitle(标题),
newscontent(正文),newdatatime(时间)。最好是写全语句,谢谢,我悬赏50分

delete a
from newstitle a
where newdatatime not in(select top 2 newdatatime from newstitle where newscontent=a.newscontent order by newdatatime )--

--查看
select *
from newstitle a
where newdatatime in(select 2 newdatatime from newstitle where newscontent=a.newscontent order by newdatatime )--保留最大的 desc

说清楚些~
select top 2 * from 表名 order by newdatatime

请说的清楚些