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.
Using Oracle...
Most of the answers listed in this discussion have answers like this:
// Solution1 -- order by desc and select topselect*from(selectround(LONG_W,4)fromSTATIONwhereLAT_N<137.2345orderbyLAT_Ndesc)whererownum=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 seekvariablemax_lat_nnumber;execselectmax(LAT_N)into:max_lat_nfromSTATIONwhereLAT_N<137.2345;selectround(LONG_W,4)fromSTATIONwhereLAT_N=:max_lat_n;
And does this subquery approach repeat the max() operation on every row?
// Solution 3 -- subquery the max() operationselectround(LONG_W,4)fromSTATIONwhereLAT_N=(selectmax(LAT_N)fromSTATIONwhereLAT_N<137.2345);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 15
You are viewing a single comment's thread. Return to all comments →
Using Oracle...
Most of the answers listed in this discussion have answers like this:
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?
And does this subquery approach repeat the max() operation on every row?