본문 바로가기
💻 하나씩 차곡차곡/프로그래머스 (SQL)

[SUM, MAX, MIN/LEVEL2] 연도별 대장균 크기의 편차 구하기 (MySQL)

by 뚜루리 2024. 10. 29.
728x90
320x100

MySQL

SELECT YEAR(DIFFERENTIATION_DATE) AS YEAR
    , MAX_SIZE_OF_COLONY - SIZE_OF_COLONY AS YEAR_DEV
    , ID
FROM ECOLI_DATA A, ( SELECT   YEAR(DIFFERENTIATION_DATE) AS YEAR
                            , MAX(SIZE_OF_COLONY) AS MAX_SIZE_OF_COLONY
                            FROM ECOLI_DATA
                            GROUP BY YEAR(DIFFERENTIATION_DATE) ) B
WHERE YEAR(DIFFERENTIATION_DATE) = B.YEAR
ORDER BY YEAR(DIFFERENTIATION_DATE), YEAR_DEV
728x90
320x100