当前位置: 代码迷 >> Sql Server >> 请教:select ID,sum(total) as Atotal from sales where Atotal>200 group by ID
  详细解决方案

请教:select ID,sum(total) as Atotal from sales where Atotal>200 group by ID

热度:417   发布时间:2016-04-24 08:59:32.0
请问:select ID,sum(total) as Atotal from sales where Atotal>200 group by ID
大概情况是把累计购买大于200元的ID筛选出来,但是
select ID,sum(total) as Atotal from sales where Atotal>200  group by ID
错误提示:Invalid column name 'Atotal' 
难道不能以sum后的字段名筛选吗?
------解决思路----------------------
不能

select ID,sum(total) as Atotal from sales  group by ID
HAVING sum(total) >200

OR

SELECT * FROM(
select ID,sum(total) as Atotal from sales  group by ID
)T
WHERE where Atotal>200
  相关解决方案