Weather Observation Station 20

IngCoding·2022년 5월 9일
1

SQL #1 문제풀이

목록 보기
35/35

문제출처 : 해커랭크

문제소개

Weather Observation Station 20

lat_n 컬럼의 중앙값을 구하고, 소수점 4자리까지 반올림하는 쿼리

풀이

  • sql 은 median 함수가 없으므로 (oracle은 있음) where문 활용
  • 중간값을 큰 값의 count와 작은 값의 count가 같은 지점으로 설정

코드

select
	round(lat_n,4)
from
	station as s 
where 
	(select count(*) from station where lat_n<s.lat_n) 
	= (select count(*) from station where lat_n>s.lat_n);
	
profile
Data & PM

0개의 댓글