Post

MySQL 주별 통계 WEEK

1. 주별 통계

WEEK 함수를 이용한다.

1) ECOLI_DATA 테이블

IDSIZE_OF_COLONYDIFFERENTIATION_DATE
1102019/01/01
222019/05/01
31002020/01/01
4172022/04/01
5102020/09/01
61012021/12/01

2) SQL

1
2
3
4
select CONCAT(WEEK(DIFFERENTIATION_DATE, 7), 'W') as WEEK
     , COUNT(SUB_CD)                              as ECOLI_COUNT
from ECOLI_DATA
group by WEEK(DIFFERENTIATION_DATE)

[출처 및 참고]

This post is licensed under CC BY 4.0 by the author.