๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SQL/SQL test

[HackerRank] Weather Observation Station 7 ํ’€์ด

by ISLA! 2023. 12. 23.

๋ฌธ์ œ

 

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

๐Ÿ‘‰ ๋„์‹œ ์ด๋ฆ„์ด ๋ชจ์Œ์œผ๋กœ ๋๋‚˜๋Š” ๊ฒƒ๋งŒ ์ฐพ๊ธฐ (๋‹จ, ์ค‘๋ณต ํ—ˆ์šฉ ์•ˆ๋จ)

Input Format

The STATION table is described as follows:

 

 

ํ’€์ด

 

  • ์ค‘๋ณต๊ฐ’ ์ œ์™ธํ•˜๊ธฐ ์œ„ํ•ด DISTINCT 
  • ๋งˆ์ง€๋ง‰ ํ•œ ๊ธ€์ž๋ฅผ ์ง€์ • : RIGHT( ์ปฌ๋Ÿผ๋ช…, 1 ) 
  • ๋งˆ์ง€๋ง‰ ํ•œ ๊ธ€์ž๊ฐ€ ๋ชจ์Œ์œผ๋กœ ๋๋‚˜๋Š” ๊ฒƒ : RIGHT( ์ปฌ๋Ÿผ๋ช…, 1 ) IN (๋ชจ์Œ)
SELECT DISTINCT CITY
FROM STATION
WHERE RIGHT(CITY, 1) IN ('a', 'e', 'i', 'o', 'u')

 

 

 

์‘์šฉ

 

โ–ถ๏ธŽ Weather Observation Station 7 : ์ฒซ ๊ธ€์ž๊ฐ€ '๋ชจ์Œ'์œผ๋กœ ์‹œ์ž‘ํ•˜์ง€ ์•Š๋Š” ๋„์‹œ๋ช… ์ถœ๋ ฅํ•˜๊ธฐ(์ค‘๋ณต ์ œ์™ธ)

SELECT DISTINCT CITY
FROM STATION
WHERE LEFT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u')

 

 

728x90