HackerRank (6) 썸네일형 리스트형 [HackerRank - SQL] The PADS 문제 Generate the following two result sets: Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in asc.. [HackerRank - SQL] Type of Triangle 문제 Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table: Equilateral: It's a triangle with 3 sides of equal length. Isosceles: It's a triangle with 2 sides of equal length. Scalene: It's a triangle with 3 sides of differing lengths. Not A Triangle: The given values of A, B, and C.. [HackerRank - SQL] Higher Than 75 Marks 문제 Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID. 풀이 SELECT Name FROM STUDENTS WHERE Marks > 75 ORDER BY RIGHT(Name, 3), ID [HackerRank - SQL] 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 9번 문제와 10번 문제의 답안을 조합하기만 하면 되는 문제였다. 풀이는 위 두 개의 링크를 참고하면 된다. SELECT DISTINCT CITY FROM STATION WHERE CITY REGEXP '^[^aeiouAEIOU].*' OR CITY REGEXP '.*[^aeiouAEIOU]$' [HackerRank - SQL] Weather Observation Station 10 문제 Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates. 풀이 MySQL에서는 정규표현식을 만족하는 문자열만 추출하기 위해 아래와 같은 방법을 사용한다. WHERE 컬럼명 REGEXP(정규표현식) 문자열의 맨 마지막을 의미하는 $기호를 이용했다. 문자열 맨 마지막에 문자가 모음이 아니어야 하므로 대괄호 안에 NOT을 의미하는 ^기호를 넣었다. SELECT DISTINCT CITY FROM STATION WHERE CITY REGEXP '.*[^aeiouAEIOU]$' [HackerRank - SQL] Weather Observation Station 9 문제 Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates. 풀이 MySQL에서는 정규표현식을 만족하는 문자열만 추출하기 위해 아래와 같은 방법을 사용한다. WHERE 컬럼명 REGEXP(정규표현식) 문자열의 맨 앞에서 시작하는 정규표현식을 만들기 위해 맨 앞에 ^를 넣었다. 모음으로 시작하지 않는 도시명을 출력하기 위해 대괄호 안에 ^를 넣었다. SELECT DISTINCT CITY FROM STATION WHERE CITY REGEXP('^[^aeiouAEIOU].*');