akmalist / HackerRank

Playground for HackerRank
0 stars 0 forks source link

Weather Observation Station 15 #10

Open akmalist opened 5 years ago

akmalist commented 5 years ago

Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345 . Round your answer to 4 decimal places.

Select CAST(LONG_W AS DECIMAL(10,4)) 
from STATION 
WHERE LAT_N = (SELECT MAX(LAT_N) FROM STATION WHERE LAT_N<137.2345);
akmalist commented 5 years ago

in MySQL

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