sql 语句,查询总数解决方案

sql 语句,查询总数一张ShopProduct表中有四个字段:ID,CreateTImes,shopID 和 leftAmount我要查询 Sum(left

sql 语句,查询总数
一张ShopProduct表中有四个字段:ID,CreateTImes,shopID 和 leftAmount 
我要查询 Sum(leftAmount)不超过 8的 shopID 和Sum(LeftAmount)
我的语句是:select * from (select SUM(sp.LeftAmount) as Amount ,sp.ShopID as shopID from ShopProduct as sp where sp.ProductID=238 group by sp.ShopID) as shopP where shopP.Amount<=8  
请问还有没有更优化的语句。

[解决办法]

SQL code
select SUM(sp.LeftAmount) as Amount ,sp.ShopID as shopID from ShopProduct as sp where sp.ProductID=238 group by sp.ShopIDhaving SUM(sp.LeftAmount)<=8
[解决办法]
select SUM(sp.LeftAmount) as Amount ,sp.ShopID as shopID from ShopProduct as sp where sp.ProductID=238 group by sp.ShopID having SUM(sp.LeftAmount) < 8