Skip to content

[1주차] 이지영 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 15, 2024
Prev Previous commit
Next Next commit
[SQL] 연도별 대장균 크기의 편차 구하기_240910
  • Loading branch information
yeongleej committed Sep 10, 2024
commit 93dddca24bb822d3fff64ad0ec7fc01ad5b8ee62
17 changes: 17 additions & 0 deletions SQL/1주차/JY_연도별_대장균_크기의_편차_구하기.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- https://school.programmers.co.kr/learn/courses/30/lessons/299310
-- year, year_dev, id
-- WITH 가상테이블 AS()

WITH MAX_COLONY AS(
SELECT YEAR(DIFFERENTIATION_DATE) AS YEAR, MAX(SIZE_OF_COLONY) AS MC
FROM ECOLI_DATA
GROUP BY YEAR(DIFFERENTIATION_DATE)
)

SELECT YEAR(C.DIFFERENTIATION_DATE) AS YEAR,
M.MC-C.SIZE_OF_COLONY AS YEAR_DEV,
C.ID
FROM ECOLI_DATA C
JOIN MAX_COLONY M
ON YEAR(C.DIFFERENTIATION_DATE) = M.YEAR
ORDER BY M.YEAR, YEAR_DEV;