采用临时表的方式来做:--创建临时表
create table tMyTab
(
autoid int,
autobrand int,
autotype int,
browsersum int
)--查询结果插入临时表
select top 10 b.[autoid],b.[autobrand],b.[autotype],sum(auto_browse_num) browsersum
into tMyTab
from AutoPrice a,AutoInfo b where a.autoid=b.autoid group by b.autoid,b.autobrand,b.autotype order by browsersum desc--加入序号
alter table tMyTab
add Seriel int identity(1,1)--查询结果
select * from tMyTab
--删除临时表
drop tMyTab
create table tMyTab
(
autoid int,
autobrand int,
autotype int,
browsersum int
)--查询结果插入临时表
select top 10 b.[autoid],b.[autobrand],b.[autotype],sum(auto_browse_num) browsersum
into tMyTab
from AutoPrice a,AutoInfo b where a.autoid=b.autoid group by b.autoid,b.autobrand,b.autotype order by browsersum desc--加入序号
alter table tMyTab
add Seriel int identity(1,1)--查询结果
select * from tMyTab
--删除临时表
drop tMyTab
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货