sql语句中的取别名?
declare@aintset@a=1declare@t2table([id]intidentity(1,1)primarykey,[name]nvarchar(200)...
declare @a int
set @a=1
declare @t2 table ([id] int identity(1,1) primary key,[name] nvarchar(200))
insert into @t2 select distinct(pzmc) from Z_YidaiZajiaozhongZhizhongTongji where nian='2003'declare @c varchar(20)
set @c=(select [name] from @t2 where [id]=@a)
select tbdw,sum(sjxj) from Z_YidaiZajiaozhongZhizhongTongji group by tbdw,pzmc,nian having pzmc=@c and nian='2003' 我想给最后查询出来的sum(sjxj)取的别名,别名必须是@c,应该怎么做啊?我用sum(sjxj)后面加 as @c 老是报错“ '@c' 附近有语法错误。”
应该怎么取呢? 展开
set @a=1
declare @t2 table ([id] int identity(1,1) primary key,[name] nvarchar(200))
insert into @t2 select distinct(pzmc) from Z_YidaiZajiaozhongZhizhongTongji where nian='2003'declare @c varchar(20)
set @c=(select [name] from @t2 where [id]=@a)
select tbdw,sum(sjxj) from Z_YidaiZajiaozhongZhizhongTongji group by tbdw,pzmc,nian having pzmc=@c and nian='2003' 我想给最后查询出来的sum(sjxj)取的别名,别名必须是@c,应该怎么做啊?我用sum(sjxj)后面加 as @c 老是报错“ '@c' 附近有语法错误。”
应该怎么取呢? 展开
1个回答
2013-05-25
展开全部
sum(sjxj) [@c]试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询