select top n 是取查询结果的前 n 条记录,如果你的结果多于 30 条。那么用 select top 30 查到的结果就只是 30 条。
解决方案 »
- JS插入数据
- 如何查询UL中LI值是否与一个给出的值相等
- extjs viewport左面板折叠展开问题
- 一个4列3行的框架布局????
- 如何将数组中的值付给变量?
- 【寻书】100分求《动态HTML参考和开发应用大全》电子书,什么版本的都成
- xxuu503(我爱郭芙蓉!) 请进!还是3组radiobutton连动的问题!
- javascript怎样读取表单数据?怎样提交到数据库?
- 框架中插入PPT的问题
- spark资源分配
- 100分求一个事件问题 第一个给出解决方案者得100分!!!
- <input name="btnSltArea" type="button" class="select_style" style="BACKGROUND-IMAGE: url(http://images.51job.com/im/mainimg/btn_
我没有说清楚.
是我之后加进去的新数据都不显示了很奇怪
就是最新的lstcmt_date
select * from
(select top 30
[auto_tpc_id]
,t.[flag]
,[checkboxid]
,[tpc_uid]
,[tpc_nick]
,[lstcmt_uid]
,[lstcmt_nick]
,[lstcmt_date]
,[tpc_title]
,[tpc_date]
,[count_read]
,[tpc_img]
,count(c.[tpc_id]) as count_cmt
from [goodluck].[dbo].[topicInfo] as t
left join [goodluck].[dbo].[commentInfo] as c
on t.auto_tpc_id = c.[tpc_id] and c.[flag] = '0'
where t.flag = '0'
group by
[auto_tpc_id]
,t.[flag]
,[checkboxid]
,[tpc_uid]
,[tpc_nick]
,[lstcmt_uid]
,[lstcmt_nick]
,[lstcmt_date]
,[tpc_title]
,[tpc_date]
,[tpc_img]
,[count_read] order by [lstcmt_date] desc--内联表加上排序
) as e
where flag = '0' AND e.[auto_tpc_id]
not in (select top 0 [auto_tpc_id]
from [goodluck].[dbo].[topicInfo]
where flag = '0' order by [lstcmt_date] desc)
order by [lstcmt_date] desc