[SQL : HackerRank] Japan Population / Weather Observation Station 2 / Weather Observation Station 18
1] Japan Population
>> 문제
Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.
Input Format
The CITY table is described as follows:
>> 문제해결 코드
SELECT SUM(POPULATION)
from CITY
WHERE COUNTRYCODE = 'JPN'
www.hackerrank.com/challenges/japan-population/problem
Japan Population | HackerRank
Query to the sum of the populations of all Japanese cities in CITY.
www.hackerrank.com
2] Weather Observation Station 2
>> 문제
Query the following two values from the STATION table:
- The sum of all values in LAT_N rounded to a scale of 2 decimal places.
- The sum of all values in LONG_W rounded to a scale of 2 decimal places.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
Output Format
Your results must be in the form:
lat lon
where lat is the sum of all values in LAT_N and lon is the sum of all values in LONG_W. Both results must be rounded to a scale of 2 decimal places.
>> 문제 해결 코드
SELECT round(sum(lat_n), 2) AS lat , round(sum(long_w), 2) AS lon
FROM STATION
hackerrank.com/challenges/weather-observation-station-2/problem
Weather Observation Station 2 | HackerRank
Write a query to print the sum of LAT_N and the sum of LONG_W separated by space, rounded to 2 decimal places.
www.hackerrank.com
3] Weather Observation Station 18
>> 문제
Consider P1(a,b ) and P2(c, d) to be two points on a 2D plane.
- a happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
- b happens to equal the minimum value in Western Longitude (LONG_W in STATION).
- c happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
- d happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points p1 and p2 and round it to a scale of 4 decimal places.
: In a plane with p1 at (x1, y1) and p2 at (x2, y2), Manhattan Distance is |x1 - x2| + |y1 - y2|.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
>> 문제 해결 코드
select ROUND(ABS(min(LAT_N) - max(LAT_N)) + ABS(min(LONG_W) - Max(LONG_W)), 4)
from station
www.hackerrank.com/challenges/weather-observation-station-18/problem
Weather Observation Station 18 | HackerRank
Query the Manhattan Distance between two points, round or truncate to 4 decimal digits.
www.hackerrank.com