求一句简单的SQL语句 有新闻表如下新闻ID,新闻标题,新闻类别(int),发布时间现在希望取出各类别下的一条新闻,根据发布时间降序 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from 新闻表 a where not exists(select 1 from 新闻表 where 新闻类别=a.新闻类别 and 发布时间>a.发布时间 )order by 新闻类别 asc--求出各类最新一条信息 select * from 新闻表 a where 新闻id=(select top1 新闻id from 新闻表 where 新闻标题=a.新闻标题 order by 发布时间 desc) select * from 新闻表 as tmpwhere not exists(select 1 from 新闻表 where 新闻类别=tmp.新闻类别 and 发布时间>tmp.发布时间) select a.* from 新闻表 a,(select 新闻类别 , max(发布时间) as 发布时间 from 新闻表 group by 新闻类别) bwhere a.新闻类别 = b.新闻类别 and a.发布时间 = b.发布时间 select * from 新闻表 as awhere not exists(select 1 from 新闻表 where 新闻类别=a.新闻类别 and 发布时间>a.发布时间) select a.* from a,(SELECT MAX(新闻ID) AS d, 新闻类别 from aGROUP BY 新闻类别) as temp1 where a.新闻ID=temp1.d order by 发布时间最正确,最好的做法 谢谢个位,个人感觉还是这样写比较好select * from 新闻 where 新闻ID in (select max(新闻ID) from 新闻 group by 类别)简单易理解 急:asp存储过程问题 在创建视图的sql语句中,是否可以先创建个临时表,再在主select语句中left join 这个临时表 求一条关于sql语句?希望大家帮忙!多谢! 请教如何用SQL实现查询从第N条到最后的数据库记录? 不行了,怎么判断都是死 需要高手帮助!怎么在SQL里面删重~? 问2个查询分析器的问题 找出一个表中同一个字段相似的值(包含关系的) 请求,一SQL 语句!关于两个表的合并! 求字段值之和满足条件的组合记录 ◆◇◆同一sql语句,有时正常,有时出错,请大家看查查是什么问题.郁闷ing◆◇◆ 怎么完全的删除一个表,包括删除它的关系,用SQL?
where not exists(select 1 from 新闻表 where 新闻类别=a.新闻类别 and 发布时间>a.发布时间 )
order by 新闻类别 asc--求出各类最新一条信息
新闻id=(select top1 新闻id from 新闻表 where 新闻标题=a.新闻标题 order by 发布时间 desc)
select * from 新闻表 as tmp
where not exists(select 1 from 新闻表 where 新闻类别=tmp.新闻类别 and 发布时间>tmp.发布时间)
(select 新闻类别 , max(发布时间) as 发布时间 from 新闻表 group by 新闻类别) b
where a.新闻类别 = b.新闻类别 and a.发布时间 = b.发布时间
GROUP BY 新闻类别) as temp1
where a.新闻ID=temp1.d order by 发布时间最正确,最好的做法
select * from 新闻 where 新闻ID in (select max(新闻ID) from 新闻 group by 类别)
简单易理解