HackerRank SQL Weather. Observation Station 14, 15

청수동햄주먹·2023년 6월 30일
0

SQL 공부

목록 보기
8/8

14: Truncate your answer to 4 decimal places

TRUNCATE(컬럼이름, 남기고 싶은 숫자 자리수)

SELECT 	TRUNCATE(MAX(LAT_N),4) 
FROM	STATION
WHERE 	LAT_N < 137.2345

15: query the western longitude for the largest northen latitude that is less than 137.2345. Round your answer to 4 decimal places

ROUND(컬럼이름, 남기고 싶은 숫자 자리수)

조건으로 건 컬럼과 보여줄 컬럼이 다르다는 것 잘 읽기

select round(long_w,4)
from station
where lat_n in (
  select max(lat_n)
  from station
  where lat_n <137.2345
)

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

이거 문제가 좀 헷갈렸다. lat_n이 38.7780 보다 큰것중 가장 작은 lat_n을 가진 도시의 long_w을 반올림해서 소수점 4번째 자리까지 구하라.

select  round(long_w,4)
from    station
where   lat_n > 38.7780
order by lat_n
limit 1;

# order + limit로 구함
profile
코딩과 사별까지

0개의 댓글