💻 하나씩 차곡차곡/프로그래머스 (SQL)

[SELECT/LEVEL3] 대장균의 크기에 따라 분류하기 2 (MySQL)

뚜루리 2024. 11. 6. 00:00
728x90
320x100

MySQL

SELECT 
ID
, CASE 
    WHEN A.PER <= 0.25 THEN 'CRITICAL'
    WHEN A.PER <= 0.5 THEN 'HIGH'
    WHEN A.PER <= 0.75 THEN 'MEDIUM'
    ELSE 'LOW' END AS COLONY_NAME
FROM ( SELECT ID
             , PERCENT_RANK() OVER (ORDER BY SIZE_OF_COLONY DESC) AS PER
    FROM ECOLI_DATA ) A
ORDER BY ID
728x90
320x100