-
I have a table that has the times of the day
SELECT * FROM horas
Columntypehora
isVARCHAR(5)
Andaquerycontainingthetimevalues
SELECTDATE_FORMAT(date,'%H:%i')HORA,TRUNCATE(MAX(humidade),2)MAX_HUMIDADE,TRUNCATE(MIN(humidade),2)MIN_HUMIDADEFROMmedicaoWHEREDATE(date)='2018-07-24'GROUPBYHOUR(date)
Whoseresultisthis:
Butwhenyoudo
join
oftablesonlyatuplecomesSELECT*FROMHORASALEFTJOIN(SELECTDATE_FORMAT(medicao.date,'%H:%i')HORA,TRUNCATE(MAX(humidade),2)MAX_HUMIDADE,TRUNCATE(MIN(humidade),2)MIN_HUMIDADEFROMmedicaoWHEREDATE(medicao.date)='2018-07-24'GROUPBYHOUR(medicao.date))BONB.HORA=A.HORA;
Theresultis:
Istartedthisquestion here if someone wanted to understand better