简体   繁体   中英

SQL query involving sub-Query

I want to write a query to find the corresponding Western Longitude value for the greatest value of the Northern Latitudes less than 137.2345 up to 4 decimal places. I wrote the following query

SELECT TO_CHAR(LONG_W,'999.9999') 
FROM STATION WHERE LAT_N =(SELECT TO_CHAR(MAX(LAT_N),'999.9999')
FROM STATION WHERE LAT_N<'137.2345');

I didn't get the ouput , Please guide me !

I had a hard time following the question. This query will give you the LONG_W for the maximum lat_n < 137.2345

select TO_CHAR(LONG_W,'999.9999')
from station where lat_n = (select max(lat_n) from station where lat_n < '137.2345')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM