读书人

怎么给结果集查询时带上序号

发布时间: 2012-04-22 18:34:46 作者: rapoo

如何给结果集查询时带上序号
rt

[解决办法]
http://www.2cto.com/database/201107/96429.htmlSQL SERVER的话这里有详细介绍。

还有一种方式是在ADOQUERY中添加一个计算栏位。
[解决办法]
select px = (select count(1) from
(
select a.type,b.type ,count(*) cnt FROM a ,b where b.r_id=a.r_id GROUP BY a.type,b.type
) m where cnt < n.cnt) + 1,* from
(
select a.type,b.type ,count(*) cnt FROM a ,b where b.r_id=a.r_id GROUP BY a.type,b.type
) n
)
--直接顺序用px = identity(int,1,1)
select px=identity(int,1,1) ,a.type,b.type ,count(*) cnt into tmp FROM a ,b where b.r_id=a.r_id GROUP BY a.type,b.type
select * from tmp

读书人网 >.NET

热点推荐