|
select unitid,unitName,(select count(*) from t_news left join t_newstype on t_news.newstypeid=t_newstype.newstypeid where t_newstype.newsTongji=1 and unitId=t_unit.unitId and sysDate > '2007.01.01' and sysDate <'2008.02.01') as newsCount,(select count(*) from t_news left join t_newstype on t_news.newstypeid=t_newstype.newstypeid where t_newstype.newsTongji=1 and unitId=t_unit.unitId and newsState=1 and sysDate > '2007.01.01' and sysDate <'2008.02.01') as newsstatecount,orderby=IDENTITY(int,1,1) into tb1 from t_unit where unitTypeId=1 order by newsCount desc,unitOrder
这个问题第1个回答:
可以创建一个临时表吧临时表的ID列设置为自增上,吧你查出来的结果排号顺序后插入到临时表里
这个问题第2个回答:
在查询该临时表的所有内容吧ID定义为排名
这个问题第3个回答:
我知道原理, 但是我不会搞啊
这个问题第4个回答:
临时表。
这个问题第5个回答:
#
这个问题第6个回答:
楼上的你无聊么, 我都说了我也知道原理, 关键是怎么执行 网上到处都是 关于 IDENTITY(int,1,1)as ss into #tb 的方法, 那东西也只能用在SQLSERVER里执行 , 在代码里怎么实现都不知道
|