我的要求是平均水平。
mychart.Activate
With mychart
.Height = rng.Height
.Width = rng.Width
.Chart.Paste
.Chart.Export Filename:=strTempfile, Filtername:="PNG"
End With
mychart.Delete
注意:仅使用单个查询即可获取平均值。
答案 0 :(得分:4)
您can't reference your previous aliases,因此您需要写出完整的语句:
SELECT
COALESCE(SUM(type = 1), 0) AS likes,
COALESCE(SUM(type = 2), 0) AS dislikes,
count(type) as total_like,
COALESCE(SUM(type = 1), 0) / COALESCE(SUM(type = 1), 0) AS average,
e_id
FROM `e_rating`
group by e_id
order by e_id ASC