728x90
반응형
문제 : Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
city의 첫번째 문자만 가져오기 위해서 SUBSTR 함수를 사용하자.
SUBSTR(str, pos, len) 로 사용할 수 있다.
MySQL : SUBSTR(), SUBSTRING()
Oracle : SUBSTR()
SQL Server : SUBSTRING()
SELECT distinct CITY
FROM STATION
WHERE SUBSTR(CITY, 1, 1) IN ('a', 'e', 'i', 'o', 'u');
Arlington Albany Upperco Aguanga Odin East China Algonac Onaway Irvington Arrowsmith Udall Oakfield Elkton East Irvine Amo Alanson Eleele Auburn Oconee Amazonia Aliso Viejo Andersonville Eros Arkadelphia Eriline Edgewater East Haddam Eastlake Addison Everton Eustis Arispe Union Star Ottertail Ermine Albion Athens Eufaula Osage City Andover Osborne Elm Grove Atlantic Mine Oshtemo Archie Olmitz Allerton Equality Alpine Ojai Orange Park Urbana Ukiah Alba Esmond Eureka Springs Eskridge Ozona Orange City Effingham Alton Agency Anthony Emmett Acme
728x90
반응형
'DB > SQL' 카테고리의 다른 글
HackerRank_14. Weather Observation Station 8 (0) | 2020.06.11 |
---|---|
HackerRank_13. Weather Observation Station 7 (0) | 2020.06.11 |
HackerRank_11. Weather Observation Station 5 (0) | 2020.06.11 |
HackerRank_10. Weather Observation Station 4 (0) | 2020.06.11 |
HackerRank_09. Weather Observation Station 3 (0) | 2020.06.11 |