컴공생의 다이어리
[프로그래머스] 입양 시각 구하기(1) - MySQL 본문
[프로그래머스] 입양 시각 구하기(1) - MySQL
GROUP BY의 HAVING 활용
SELECT HOUR(DATETIME) AS HOUR, COUNT(DATETIME) AS COUNT FROM ANIMAL_OUTS
GROUP BY HOUR(DATETIME) HAVING HOUR >=9 AND HOUR <=19
ORDER BY HOUR;
# or
SELECT HOUR(DATETIME) AS HOUR, COUNT(DATETIME) AS COUNT FROM ANIMAL_OUTS
GROUP BY HOUR(DATETIME) HAVING HOUR BETWEEN 9 AND 19
ORDER BY HOUR;
WHERE 활용
SELECT HOUR(DATETIME) AS HOUR, COUNT(DATETIME) AS COUNT FROM ANIMAL_OUTS
WHERE HOUR(DATETIME) >=9 AND HOUR(DATETIME) <=19
GROUP BY HOUR(DATETIME)
ORDER BY HOUR;
# or
SELECT HOUR(DATETIME) AS HOUR, COUNT(DATETIME) AS COUNT FROM ANIMAL_OUTS
WHERE HOUR(DATETIME) BETWEEN 9 AND 19
GROUP BY HOUR(DATETIME)
ORDER BY HOUR;
https://programmers.co.kr/learn/courses/30/lessons/59412
728x90
반응형
'Development > Algorithm & Coding Test' 카테고리의 다른 글
[알고리즘] 선형 탐색(Linear Search) (0) | 2022.04.14 |
---|---|
[프로그래머스] 입양 시각 구하기(2) - MySQL (0) | 2022.04.13 |
[프로그래머스] 동명 동물 수 찾기 - MySQL (0) | 2022.04.11 |
[프로그래머스] 고양이와 개는 몇 마리 있을까 - MySQL (0) | 2022.04.10 |
[알고리즘] 이진(이분) 탐색(Binary Search) (0) | 2022.04.09 |
Comments