We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Weather Observation Station 15
Weather Observation Station 15
+ 11 comments Note to the respected moderators: the problem statement is not clear at all and is quite confusing.
+ 3 comments MySql: Select round(long_w,4) from Station where lat_n < 137.2345 order by lat_n desc limit 1;
+ 6 comments MySQL solution
From my HackerRank solutions.
SELECT ROUND(LONG_W, 4) FROM STATION WHERE LAT_N < 137.2345 ORDER BY LAT_N DESC LIMIT 1;
Let me know if you have any questions.
+ 1 comment Using Oracle...
Most of the answers listed in this discussion have answers like this:// Solution1 -- order by desc and select top select * from (select round(LONG_W,4) from STATION where LAT_N<137.2345 order by LAT_N desc) where rownum=1;
Is there anything worse about this pattern? I would have thought ordering was more resource intensive than assigning a variable and seeking. Is there a reason not to do this?
// Solution 2 -- assign max_lat_n variable and seek variable max_lat_n number; exec select max(LAT_N) into :max_lat_n from STATION where LAT_N<137.2345; select round(LONG_W,4) from STATION where LAT_N=:max_lat_n;
And does this subquery approach repeat the max() operation on every row?// Solution 3 -- subquery the max() operation select round(LONG_W,4) from STATION where LAT_N=(select max(LAT_N) from STATION where LAT_N<137.2345);
+ 0 comments select round (long_w,4) from station where lat_n = (select max(lat_n) from station where lat_n<137.2345);
Load more conversations
Sort 1051 Discussions, By:
Please Login in order to post a comment