IFNULL (1) 썸네일형 리스트형 [프로그래머스] GROUP BY - 입양 시각 구하기(2) / 매 시간대별 통계, JOIN, IFNULL 문제 풀이 SELECT T1.HOURS AS HOUR, IFNULL(T2.COUNT,0) AS COUNT FROM (SELECT @N := @N + 1 AS HOURS FROM ANIMAL_OUTS, (SELECT @N := -1 FROM DUAL) NN LIMIT 24 )T1 LEFT JOIN (SELECT HOUR(DATETIME) AS HOUR, COUNT(*)AS COUNT FROM ANIMAL_OUTS WHERE HOUR(DATETIME) BETWEEN '0' AND '24' -- 없으면 오류남! GROUP BY HOUR(DATETIME) ORDER BY HOUR(DATETIME))T2 ON T1.HOURS = T2.HOUR 해결 과정 1. 0~23까지 증가하는 컬럼(테이블에서의 각 열에 해당).. 이전 1 다음