인프런- 데이터 분석을 위한 고급 SQL 문제풀이 : 섹션1 - Weather Observation Station 17 문제풀이

르네·2023년 10월 9일
0

SQL

목록 보기
40/63

본 내용은 데이터리안 '데이터 분석을 위한 고급 SQL 문제풀이'을 수강하며 작성한 내용입니다.

문제 1 (틀림)

https://www.hackerrank.com/challenges/weather-observation-station-17/problem?isFullScreen=true

Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than . Round your answer to decimal places.

Input Format

The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

풀이

- 나의 풀이과정

SELECT ROUND(long_w, 4)
FROM station
WHERE (
        SELECT MIN(lat_n)
        FROM station
      ) sub
      AND sub > 38.7780

: 에러뜸! 서브쿼리 활용해서 풀어봤는데, 서브쿼리 식구현이 아직 완전히 납득이 안되는 것 같다.

- 선생님 풀이

SELECT ROUND(long_w, 4)
FROM station
WHERE lat_n >38.7780
ORDER BY lat_n
LIMIT 1

배운점

  • 최소값 데이터를 MIN()으로 뿐만 아니라 ORDER BY와 LIMIT으로도 구현해줄 수 있다.
profile
데이터분석 공부로그

0개의 댓글