sql server2000 如何让数字作为列名,用如下语句总是提示数字附近有语法错误,把数字改成大写就没有问题
selectt.字段4,sum(t.1303)as1303收入,sum(t.1302)as1302收入,sum(t.1303)-sum(t.1302)as差值from(s...
select t.字段4,sum(t.1303) as 1303收入,sum(t.1302) as 1302收入, sum(t.1303) - sum(t.1302) as 差值 from (select 字段4,字段18 as 1303,0 as 1302 from [1303] union all select 字段4,0 as 1303,字段18 as 1302 from [1302] ) t group by t.字段4 having sum(t.1303) - sum(t.1302) > 300;
现在必须使用数字作为列名,该怎么办? 展开
现在必须使用数字作为列名,该怎么办? 展开
2013-05-20
展开全部
select
t.字段4,
sum([t.1303]) as [1303收入],
sum([t.1302]) as [1302收入],
sum([t.1303]) - sum([t.1302]) as 差值
from
(select
字段4,
字段18 as [1303],
0 as [1302]
from [1303]
union all
select
字段4,
0 as [1303],
字段18 as [1302]
from [1302]
) t
group by
t.字段4
having sum([t.1303]) - sum([t.1302]) > 300;
t.字段4,
sum([t.1303]) as [1303收入],
sum([t.1302]) as [1302收入],
sum([t.1303]) - sum([t.1302]) as 差值
from
(select
字段4,
字段18 as [1303],
0 as [1302]
from [1303]
union all
select
字段4,
0 as [1303],
字段18 as [1302]
from [1302]
) t
group by
t.字段4
having sum([t.1303]) - sum([t.1302]) > 300;
展开全部
数字用单引号引起来嘛
as 1303 --> as '1303'
as 1303 --> as '1303'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql不能用数字作列名,试试用[]把数字括起来。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select id as '123' from tabname
追问
不行,因为t.1303部分没有解决,此部分若加引号则提示不能对字符串求和。
追答
那就别想着用数字做列名,换一种实现方式。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询