Revising the Select Query

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

CITY.jpg

Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.

select * from CITY where population>100000 AND countrycode='USA';

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

Query all columns (attributes) for every row in the CITY table.

Query all columns for a city in CITY with the ID 1661.

Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.

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.

Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.

Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. The STATION table is described as follows:

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

Weather Observation Station 5

Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.

Sample Input

For example, CITY has four entries: DEF, ABC, PQRS and WXY.

Sample Output

요놈은 생각하기 좀 힘들었다.. 내일 다시 곱씹어보자..! -> 1.30:킹만하쥬?

Weather Observation Station 6

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

DISTINCT로 하나만 출력되게 하고, WHERE 절에서 LIKE을 사용하고 OR조건을 사용해서 찾는 방식

정규표현식을 사용해서도 가능하구나 정도? ->https://yongku.tistory.com/entry/HackerRank-Weather-Observation-Station-6-오라클Oraclearrow-up-right에서 알게되었음

Weather Observation Station 7

Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.

위 문제와 같은 맥락이다. 밑에 방식도 매우 흥미로웠다..! sql을 짤라서 비교하는 방식도 있다는 것이..!

Weather Observation Station 8

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.

음.. 그렇게 어렵지 않게 푸니까 이렇게 나오는데 어떻게 더 간단하게 할 수 있을까를 생각해보자

Weather Observation Station 9

Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

위의 쿼리는 할만한디... 문제는 밑에 쪽 쿼리다 -> 정규 표현식을 사용하는 방법을 조금 더 알아보

Weather Observation Station 10

Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates.

시작에 대한 정규식을 사용하는 방법은 ^[무슨알파벳~] 이렇게 사용하고

끝나는 것에 대한 정규식을 사용하는 방법은 [무슨알파벳~]$ 이렇게 사용한다!

Weather Observation Station 11

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.

Weather Observation Station 12

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.

Last updated