Weather Observation2 - SQL
Weather Observation 시리즈 SQL 문제 풀이 2
Weather Observation Station 11
https://www.hackerrank.com/challenges/weather-observation-station-11/problem
Weather Observation Station 11 | HackerRank
Query a list of CITY names not starting or ending with vowels.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[^aeiou]|[^aeiou]$'
Weather Observation Station 12
https://www.hackerrank.com/challenges/weather-observation-station-12/problem
Weather Observation Station 12 | HackerRank
Query an alphabetically ordered list of CITY names not starting and ending with vowels.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city NOT LIKE 'a%'
AND city NOT LIKE 'e%'
AND city NOT LIKE 'i%'
AND city NOT LIKE 'o%'
AND city NOT LIKE 'u%'
AND city NOT LIKE '%e'
AND city NOT LIKE '%i'
AND city NOT LIKE '%o'
AND city NOT LIKE '%u'
AND city NOT LIKE '%a'
Weather Observation Station 13
https://www.hackerrank.com/challenges/weather-observation-station-13/problem
Weather Observation Station 13 | HackerRank
Query the sum of Northern Latitudes having values greater than 38.7880 and less than 137.2345, truncated to 4 decimal places.
www.hackerrank.com
SELECT TRUNCATE(SUM(LAT_N), 4)
FROM station
WHERE LAT_N BETWEEN 38.7880 AND 137.2345
Weather Observation Station 14
https://www.hackerrank.com/challenges/weather-observation-station-14/problem
Weather Observation Station 14 | HackerRank
Query the greatest value of the Northern Latitudes from STATION that are under 137.2345 and truncated to 4 decimal places.
www.hackerrank.com
SELECT TRUNCATE(MAX(LAT_N), 4)
FROM station
WHERE LAT_N < 137.2345
Weather Observation Station 15
https://www.hackerrank.com/challenges/weather-observation-station-15/problem
Weather Observation Station 15 | HackerRank
Query the Western Longitude for the largest Northern Latitude under 137.2345, rounded to 4 decimal places.
www.hackerrank.com
SELECT ROUND(LONG_W,4)
FROM station
WHERE LAT_N < 137.2345
ORDER BY LAT_N DESC
LIMIT 1
Weather Observation Station 16
https://www.hackerrank.com/challenges/weather-observation-station-16/problem
Weather Observation Station 16 | HackerRank
Query the smallest of STATION's Northern Latitudes that is greater than 38.7780, and round to 4 decimal places
www.hackerrank.com
SELECT ROUND(MIN(LAT_N), 4)
FROM station
WHERE LAT_N > 38.7780
Weather Observation Station 17
https://www.hackerrank.com/challenges/weather-observation-station-17/problem
Weather Observation Station 17 | HackerRank
Query the Western Longitude for the smallest value of the Northern Latitudes greater than 38.7780 in STATION and round to 4 decimal places.
www.hackerrank.com
SELECT ROUND(LONG_W, 4)
FROM station
WHERE LAT_N > 38.7780
ORDER BY LAT_N
LIMIT 1;
Weather Observation Station 18
https://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
SELECT ROUND(ABS(MIN(lat_n)-MAX(lat_n))+
ABS(MIN(long_w)-MAX(long_w)), 4)
FROM station
Weather Observation Station 19
https://www.hackerrank.com/challenges/weather-observation-station-19/problem
Weather Observation Station 19 | HackerRank
Query the Euclidean Distance between two points and round to 4 decimal digits.
www.hackerrank.com
SELECT ROUND(SQRT(POWER(MAX(LAT_N) - MIN(LAT_N), 2)
+ POWER(MAX(LONG_W) - MIN(LONG_W), 2)), 4)
FROM station