select * from(
select t.articleid,t.filt_content,t.stat,t.createdate,s.articlename
from pms_wapcomment t
inner join pms_article s on t.articleid=s.id
where t.stat=1
order by t.createdate desc)
group by t.articleid
where rownum <=5
我想按文章ID分组,可是说命令未正确结束
请高手指点
------解决方案--------------------------------------------------------
比如有三列
1,'aa'
2,'bb'
2,'cc'
你现在按照ID进行分组了,id=2的有两列,你通过'*'来检索字段,
你让oracle是选'bb',还是'cc'呢?
所以,你必须只能够检索出你分组的字段
select t.articleid from(
select t.articleid,t.filt_content,t.stat,t.createdate,s.articlename
from pms_wapcomment t
inner join pms_article s on t.articleid=s.id
where t.stat=1
order by t.createdate desc)
group by t.articleid
where rownum <=5
------解决方案--------------------------------------------------------