๐Ÿ’ SQL/Group By

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit: ์ž๋™์ฐจ ์ข…๋ฅ˜ ๋ณ„ ํŠน์ • ์˜ต์…˜์ด ํฌํ•จ๋œ ์ž๋™์ฐจ ์ˆ˜ ๊ตฌํ•˜๊ธฐ

์„ ๋‹ฌ 2023. 4. 21. 23:54
๋ฐ˜์‘ํ˜•

https://school.programmers.co.kr/learn/courses/30/lessons/151137

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

 

-- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”
SELECT CAR_TYPE, COUNT(*) as CARS
from CAR_RENTAL_COMPANY_CAR
where OPTIONS like "%๊ฐ€์ฃฝ์‹œํŠธ%" or OPTIONS like "%์—ด์„ ์‹œํŠธ%" or OPTIONS like "%ํ†ตํ’์‹œํŠธ%" 
group by CAR_TYPE
order by CAR_TYPE asc
๋ฐ˜์‘ํ˜•