首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这句话那么长,小弟我如何改它的别名呢

2012-02-04 
这句话那么长,我怎么改它的别名呢?update#tempsetpmb.pmfrom#tempa,(selectdistinctcj,(selectcount(*)+1

这句话那么长,我怎么改它的别名呢?
update       #temp       set       pm=b.pm       from       #temp       a,(select       distinct       cj,(select       count(*)+1       from       #temp       where       cj> a.cj       )       as       pm       from       #temp       a       )       b       where       a.cj=b.cj    
如果我在用这句话时,由于觉得pm太长,我想用p代替,怎么写呢

[解决办法]
update #temp set pm=b.p from #temp a,(select distinct cj,(select count(*)+1 from #temp where cj> a.cj ) as p from #temp a ) b where a.cj=b.cj

热点排行