Weather Observation - SQL
Weather Observation 시리즈 SQL 문제 풀이
Weather Observation Station 1
https://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
SELECT city, state
FROM station
Weather Observation Station 2
https://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
SELECT ROUND(SUM(lat_n), 2)
, ROUND(SUM(long_w), 2)
FROM station
Weather Observation Station 3
https://www.hackerrank.com/challenges/weather-observation-station-3/problem
Weather Observation Station 3 | HackerRank
Query a list of unique CITY names with even ID numbers.
www.hackerrank.com
SELECT Distinct city
FROM station
WHERE (id % 2) = 0
Weather Observation Station 4
https://www.hackerrank.com/challenges/weather-observation-station-4/problem
Weather Observation Station 4 | HackerRank
Find the number of duplicate CITY names in STATION.
www.hackerrank.com
SELECT COUNT(city)-COUNT(DISTINCT city)
FROM station
Weather Observation Station 5
https://www.hackerrank.com/challenges/weather-observation-station-5/problem
Weather Observation Station 5 | HackerRank
Write a query to print the shortest and longest length city name along with the length of the city names.
www.hackerrank.com
SELECT city, LENGTH(city)
FROM STATION
ORDER BY LENGTH(city) DESC, city
LIMIT 1;
Weather Observation Station 6
https://www.hackerrank.com/challenges/weather-observation-station-6/problem
Weather Observation Station 6 | HackerRank
Query a list of CITY names beginning with vowels (a, e, i, o, u).
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city LIKE 'a%'
OR city LIKE 'e%'
OR city LIKE 'i%'
OR city LIKE 'o%'
OR city LIKE 'u%'
Weather Observation Station 7
https://www.hackerrank.com/challenges/weather-observation-station-7/problem
Weather Observation Station 7 | HackerRank
Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city REGEXP '[aeiou]$'
Weather Observation Station 8
https://www.hackerrank.com/challenges/weather-observation-station-8/problem
Weather Observation Station 8 | HackerRank
Query CITY names that start AND end with vowels.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[aeiou].*[aeiou]$'
Weather Observation Station 9
https://www.hackerrank.com/challenges/weather-observation-station-9/problem
Weather Observation Station 9 | HackerRank
Query an alphabetically ordered list of CITY names not starting with vowels.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[^aeiou]'
Weather Observation Station 10
https://www.hackerrank.com/challenges/weather-observation-station-10/problem
Weather Observation Station 10 | HackerRank
Query a list of CITY names not ending in vowels.
www.hackerrank.com
SELECT DISTINCT city
FROM station
WHERE city REGEXP '[^aeiou]$'