MySQL 분기별 통계 QUARTER
1. 분기별 통계
QUARTER 함수를 이용한다.
1) ECOLI_DATA
테이블
ID | SIZE_OF_COLONY | DIFFERENTIATION_DATE |
---|---|---|
1 | 10 | 2019/01/01 |
2 | 2 | 2019/05/01 |
3 | 100 | 2020/01/01 |
4 | 17 | 2022/04/01 |
5 | 10 | 2020/09/01 |
6 | 101 | 2021/12/01 |
2) SQL
1
2
3
4
5
SELECT CONCAT(QUARTER(DIFFERENTIATION_DATE), 'Q') AS QUARTER
, COUNT(SIZE_OF_COLONY) AS ECOLI_COUNT
FROM ECOLI_DATA
GROUP BY QUARTER
order by QUARTER asc
[출처 및 참고]
This post is licensed under CC BY 4.0 by the author.