[SQL문제풀기] 서울숲 요일별 대기오염도 계산하기

silver's avatar
Sep 20, 2025
[SQL문제풀기] 서울숲 요일별 대기오염도 계산하기
Contents
문제SQLite

문제

SQLite

내가 작성한 정답

select case strftime('%w',measured_at) when '0' then '일요일' when '1' then '월요일' when '2' then '화요일' when '3' then '수요일' when '4' then '목요일' when '5' then '금요일' when '6' then '토요일' end weekday, round(avg(no2),4) no2, round(avg(o3),4) o3, round(avg(co),4) co, round(avg(so2),4) so2, round(avg(pm10),4) pm10, round(avg(pm2_5),4) pm2_5 from measurements group by weekday order by case weekday when '월요일' then 1 when '화요일' then 2 when '수요일' then 3 when '목요일' then 4 when '금요일' then 5 when '토요일' then 6 when '일요일' then 7 end asc;
DBMS
요일 추출 함수
정렬 방식
SQLite
strftime('%w', measured_at)
CASE 문 활용
Oracle
TO_CHAR(measured_at, 'DAY', 'NLS_DATE_LANGUAGE=KOREAN')
TO_CHAR(measured_at, 'D') 활용
MySQL
DAYOFWEEK(measured_at)
FIELD() 활용
 
Share article

silver