SQL

HackerRank 해커랭크 SQL 예제 추가 풀이 (1)

얆생 2023. 6. 23. 10:58

1. https://www.hackerrank.com/challenges/revising-the-select-query-2/problem?isFullScreen=true 

 

Revising the Select Query II | HackerRank

Query the city names for all American cities with populations larger than 120,000.

www.hackerrank.com

Q: Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.

The CITY table is described as follows:

A:

SELECT name
FROM city
WHERE population > 120000 AND CountryCode = 'USA'

 

 

 

2. https://www.hackerrank.com/challenges/japanese-cities-attributes/problem?isFullScreen=true 

 

Japanese Cities' Attributes | HackerRank

Query the attributes of all the cities in Japan.

www.hackerrank.com

Q: Query all attributes of every Japanese city in the CITY table.

The COUNTRYCODE for Japan is JPN.

The CITY table is described as follows:

A: 

SELECT *
FROM city
WHERE countrycode = 'JPN'

 

 

 

3. https://www.hackerrank.com/challenges/japanese-cities-name/problem?isFullScreen=true 

 

Japanese Cities' Names | HackerRank

In this challenge, you will query a list of all the Japanese cities' names.

www.hackerrank.com

Q: Query the names of all the Japanese cities in the CITY table.

The COUNTRYCODE for Japan is JPN.
The CITY table is described as follows:

A:

SELECT name
FROM city
WHERE countrycode = 'JPN'

 

 

 

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

Q: Query the list of CITY names from STATION that either do not start with vowels or 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%')
OR (city NOT LIKE '%a'
AND city NOT LIKE '%e'
AND city NOT LIKE '%i'
AND city NOT LIKE '%o'
AND city NOT LIKE '%u')

- 어려워서 해설 참조함..ㅜ