日期:2014-05-19  浏览次数:20418 次

sql server2000不支持用列别名运算吗?
比方说
select   col1   as   a,col2   as   b,   (a+b)   as   c   from   table
这种写法不支持吗?

我知道它支持 col1+col2这种情况,可为什么用别名就不可以呢

在access里面是支持的

哪位高手给解释一下吧,谢谢

------解决方案--------------------
可以这样

select a,b,c=a+b from
(
select col1 as a,col2 as b from table
)t
------解决方案--------------------
哦..我只是知道不支持
------解决方案--------------------
select a,b,(a+b) as C
from (select col1 as a,col2 as b from [table]) AS T

------解决方案--------------------
select (a+b) as c
from (
select col1 as a,
col2 as b
from table) as tmp
------解决方案--------------------
--谁说不行呀,我用示例证明
create table #
(
a int,
b int
)

insert into #
select 12,89 union all
select 2,897 union all
select 12,89 union all
select 2,897 union all
select 12,89 union all
select 2,897 union all
select 12,89 union all
select 2,897 union all
select 12,89 union all
select 2,897

select a as 第一列,b as 第二列,a+b as 第三列
from #
=============
结果:
第一列 第二列 第三列
----------- ----------- -----------
12 89 101
2 897 899
12 89 101
2 897 899
12 89 101
2 897 899
12 89 101
2 897 899
12 89 101
2 897 899

(所影响的行数为 10 行)