Why this query does not work ? It is a type of subquery right ? and it also seems logically correct?

Issue

select ROUND(LONG_W,4)
from STATION
WHERE LAT_N = MAX(SELECT LAT_N FROM STATION WHERE LAT_N < 137.2345);

Why this query will not work for the question .

https://www.hackerrank.com/challenges/weather-observation-station-15/problem

Solution

Try this easy way.

select ROUND(LONG_W,4) from STATION WHERE LAT_N < 137.2345 ORDER BY LAT_N DESC LIMIT 0,1

Answered By – MD TAREK HOSSEN

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published