SELECT
DATE(DTM) AS'Dia',
ROUND(COUNT(TMP)/4) AS 'Oídio'
CASE
ROUND(COUNT(TMP)/4)>=6 THEN '20'
ROUND(COUNT(TMP)/4)<6 THEN '-10'
END
FROM dados_meteo
WHERE TMP>=20 AND TMP<=30
GROUP BY DATE(DTM)
答案 0 :(得分:4)
你也许正在寻找这个吗?
SELECT
DATE(DTM) AS 'Dia',
ROUND(COUNT(TMP)/4) AS 'Oídio',
CASE
WHEN ROUND(COUNT(TMP)/4)>=6 THEN '20'
WHEN ROUND(COUNT(TMP)/4)<6 THEN '-10'
END
FROM dados_meteo
WHERE TMP>=20 AND TMP<=30
GROUP BY DATE(DTM)
您需要使用WHEN
标记CASE
的分支,并且您在CASE
之前缺少逗号。