SQL & DB/HackerRank SQL Problem

[HackerRank SQL] Weather Observation Station 1, 2 (MySQL)

YSY^ 2021. 2. 27. 17:00

www.hackerrank.com/challenges/weather-observation-station-1/problem

 

Weather Observation Station 1 | HackerRank

Write a query to print the CITY and STATE for each attribute in the STATION table.

www.hackerrank.com

Query a list of CITY and STATE from the STATION table.
The STATION table is described as follows:

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


Answer

select city, state
from station;

www.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

Query the following two values from the STATION table:

  1. The sum of all values in LAT_N rounded to a scale of  decimal places.
  2. The sum of all values in LONG_W rounded to a scale of  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  is the sum of all values in LAT_N and  is the sum of all values in LONG_W. Both results must be rounded to a scale of  decimal places.


select round(sum(lat_n),2), round(sum(long_w),2)
from station
728x90
반응형