HackerRank Weather Observation Station 17 problem solution

In this HackerRank Weather Observation Station 17 problem solution Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780. Round your answer to 4 decimal places.

Input Format

The STATION table is described as follows:

HackerRank Weather Observation Station 17 problem solution

where LAT_N is the northern latitude and LONG_W is the western longitude.


Problem solution MS SQL.

SELECT TOP 1 FORMAT(LONG_W, 'F4') 
from station
WHERE LAT_N > 38.7780 
ORDER BY LAT_N ASC

Problem solution in Oracle.

select to_char(LONG_W ,'fm999999.9999')
from station
where (select min(LAT_N) from station where LAT_N > 38.7780) = LAT_N;


Problem solution in DB2.

/*
    Enter your query here and follow these instructions:
    1. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
    2. The AS keyword causes errors, so follow this convention: "Select t.Field From table1 t" instead of "select t.Field From table1 AS t"
    3. Type your code immediately after comment. Don't leave any blank line.
*/
select round(decfloat(LONG_W), 4) from STATION where LAT_N > 38.7780 order by LAT_N  fetch first row only;


Post a Comment

0 Comments