我是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
然后出现一个错误,说
无效的列名“ year”。
为什么会这样,我该怎么办?
大概您想要的查询是:
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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句