Growth ๐ŸŒณ/Practice ๐Ÿ’ป

[Hacker Rank] Weather Observation Station 14

์ธ” 2022. 8. 22. 11:47

๐Ÿ“ข ๋ณธ ํฌ์ŠคํŒ…์— ํ™œ์šฉ๋˜๋Š” ๊ธฐ๋ณธ ๋ฌธ์ œ ๋ฐ ์ž๋ฃŒ ์ถœ์ฒ˜๋Š” HackerRank ์ž„์„ ๋ฐํž™๋‹ˆ๋‹ค.

https://www.hackerrank.com


โ–  ๋ฌธ์ œ

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

 

Weather Observation Station 14 | HackerRank

Query the greatest value of the Northern Latitudes from STATION that are under 137.2345 and truncated to 4 decimal places.

www.hackerrank.com

 

SELECT TRUNCATE(LAT_N, 4)
 FROM STATION
 WHERE LAT_N < 137.2345
 ORDER BY 1 DESC
 LIMIT 1;

Query the greatest value of the Northern Latitudes (LAT_N) from STATION that is less than . Truncate 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.


โ–  ํ’€์ด

 

ํ’€์ด1)

SELECT TRUNCATE(LAT_N, 4)
 FROM STATION
 WHERE LAT_N < 137.2345
 ORDER BY 1 DESC
 LIMIT 1;

๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌํ•ด์„œ LIMIT์œผ๋กœ ์ถœ๋ ฅ๋˜๋Š” ํ–‰ ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•ด์คฌ๋‹ค.

137.0193

 

ํ’€์ด2)

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

 FROM ์ ˆ์— ์„œ๋ธŒ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ LAT_N์ด 137.2345 ๋ฏธ๋งŒ์ธ ์Šคํ…Œ์ด์…˜์ค‘์— ์ตœ๋Œ€๊ฐ’์„ ์ถ”์ถœํ–ˆ๋‹ค.

TRUNCATE ํ•จ์ˆ˜๋Š” ์•„๋ž˜์ฒ˜๋Ÿผ ๋ฉ”์ธ SELECT์ ˆ์—์„œ ์ถ”์ถœํ•ด๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

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

'Growth ๐ŸŒณ > Practice ๐Ÿ’ป' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Hacker Rank] Type of Triangle  (0) 2022.08.24
[Hacker Rank] Weather Observation Station 16  (0) 2022.08.22
[Hacker Rank] The Blunder  (0) 2022.08.20
[SQL] ์—ฐ์Šต๋ฌธ์ œ  (0) 2022.08.03
[Hacker Rank] Weather Observation Station 20 : MySQL  (0) 2022.08.02