Hello coders, today we are going to solve Weather Observation Station 13 HackerRank Solution in SQL.
Problem
Query the sum of Northern Latitudes (LAT_N) from STATION having values greater than 38.7880 and less than 137.2345. Truncate your answer to 4 decimal places.
Input Format
The STATION table is described as follows:
Field | Type |
---|---|
ID | NUMBER |
CITY | VARCHAR2(21) |
STATE | VARCHAR2(2) |
LAT_N | NUMBER |
Long_W | NUMBER |
where LAT_N is the northern latitude and LONG_W is the western longitude.
Solution – Weather Observation Station 13 in SQL
MySQL
select round(sum(lat_n), 4) from station where lat_n > 38.7880 and lat_n < 137.2345;
Disclaimer: The above Problem (Weather Observation Station 13) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.
IN MS SQL:
SELECT CONVERT(DECIMAL(15,4),SUM(LAT_N)) FROM STATION WHERE LAT_N BETWEEN 38.7880 AND 137.2345
SELECT ROUND(SUM(LAT_N),4)
FROM STATION
WHERE LAT_N BETWEEN 38.7780 AND 137.2345