๐Ÿ’ SQL/Group By

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit: ์ง„๋ฃŒ๊ณผ๋ณ„ ์ด ์˜ˆ์•ฝ ํšŸ์ˆ˜ ์ถœ๋ ฅํ•˜๊ธฐ

์„ ๋‹ฌ 2023. 3. 1. 01:43
๋ฐ˜์‘ํ˜•

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

 

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

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

programmers.co.kr

 

 

-- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”
SELECT MCDP_CD as '์ง„๋ฃŒ๊ณผ์ฝ”๋“œ', count(APNT_NO) as '5์›”์˜ˆ์•ฝ๊ฑด์ˆ˜'
from APPOINTMENT 
where APNT_YMD between '2022-05-01' and '2022-05-31'
group by MCDP_CD
order by count(APNT_NO), MCDP_CD;
๋ฐ˜์‘ํ˜•