WHERE문 해커랭크 예제 풀이(DISTINCT, NOT LIKE)
1. https://www.hackerrank.com/challenges/revising-the-select-query/problem?isFullScreen=true
Revising the Select Query I | HackerRank
Query the data for all American cities with populations larger than 100,000.
www.hackerrank.com
Q: Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.
The CITY table is described as follows:
A:
SELECT *
FROM city
WHERE population > 100000
AND CountryCode = 'USA'
2. https://www.hackerrank.com/challenges/select-by-id/problem?isFullScreen=true
Select By ID | HackerRank
Query the details of the city with ID 1661.
www.hackerrank.com
Q: Query all columns for a city in CITY with the ID 1661.
The CITY table is described as follows:
A:
SELECT *
FROM city
WHERE id = 1661
3. https://www.hackerrank.com/challenges/weather-observation-station-6/problem?isFullScreen=true
Weather Observation Station 6 | HackerRank
Query a list of CITY names beginning with vowels (a, e, i, o, u).
www.hackerrank.com
Q: Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
A:
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%'
4. https://www.hackerrank.com/challenges/weather-observation-station-12/problem?isFullScreen=true
Weather Observation Station 12 | HackerRank
Query an alphabetically ordered list of CITY names not starting and ending with vowels.
www.hackerrank.com
Q: Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
A:
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 '%a'
AND city NOT LIKE '%e'
AND city NOT LIKE '%i'
AND city NOT LIKE '%o'
AND city NOT LIKE '%u'
- NOT LIKE 이용