-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from dejavuhyo/patch-2024-11-18
feat(posts): create 2024-11-18-mysql-week
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: MySQL 주별 통계 WEEK | ||
author: dejavuhyo | ||
date: 2024-11-18 10:20:00 +0900 | ||
categories: [Database, MySQL] | ||
tags: [mysql-week, week, mysql-주별-통계, 주별-통계] | ||
--- | ||
|
||
## 1. 주별 통계 | ||
WEEK 함수를 이용한다. | ||
|
||
### 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 | ||
|
||
```sql | ||
select CONCAT(WEEK(DIFFERENTIATION_DATE, 7), 'W') as WEEK | ||
, COUNT(SUB_CD) as ECOLI_COUNT | ||
from ECOLI_DATA | ||
group by WEEK(DIFFERENTIATION_DATE) | ||
``` | ||
|
||
## [출처 및 참고] | ||
* [https://soobindeveloper8.tistory.com/932](https://soobindeveloper8.tistory.com/932) |