只有当值大于零时,我才想取行的平均值。但是,我收到以下错误:
'列 'Daily.Rad' 在选择列表中无效,因为它不包含在聚合函数或 GROUP BY 中...'
代码:
SELECT Date,
AVG([Speed]) as [Speed],
CASE WHEN [Rad] > 0.0
THEN AVG([Rad])
ELSE 0.0
END AS [Rad],
AVG([Pressure]) as [Pressure],
FROM Daily
WHERE MONTH(Date) = MONTH('08/31/2011')
GROUP BY Date