我是SQL的新手。我没有写入权限,所以我创建了一个临时表#temp
并执行了以下操作:
select
*, round(var1/100,0) as year
from #temp
select
id_bucket, year, sum(b_flag) as num_b
from
#temp
group by
id_bucket, year
order by
id_bucket, year
然后发生错误,说
无效的列名'年'。
为什么这样,我该怎么办?
答案 0 :(得分:1)
大概你想要的查询是:
select id_bucket, round(var1 / 100,0), sum(b_flag) as num_b
from #temp
group by id_bucket, round(var1 / 100, 0)
order by id_bucket, round(var1 / 100, 0);