I have a duplicated COUNT on this query:
SELECT
DATE(dia.DTM) AS 'Dia',
COUNT(temp.TMP) AS 'Index'
FROM dados_meteo dia
INNER JOIN dados_meteo temp
ON temp.DTM = dia.DTM
AND temp.TMP BETWEEN 20 AND 30
WHERE dia.POM = 'Alcobaca'
GROUP BY DATE(dia.DTM)
If I understand correctly (please describe exacly what you want the query to do), you’ll get what you want by changing
INNER JOINtoLEFT JOIN.Or by this:
What the above query is actually doing is this:
After the comments, here’s a slight modification: