๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋ชฉ๋กOrderBy (1)

Soy Library

[ํ˜ผ๊ณตS] CH3-(2). ์ข€ ๋” ๊นŠ๊ฒŒ ์•Œ์•„๋ณด๋Š” SELECT๋ฌธ

์ด ์ ˆ์—์„œ๋Š” SELECT ๋ฌธ์—์„œ ๊ฒฐ๊ณผ ์ •๋ ฌ์„ ์œ„ํ•œ ORDER BY, ๊ฒฐ๊ณผ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ œํ•œํ•˜๋Š” LIMIT, ์ค‘๋ณต๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” DISTINCT ๋“ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฒ•์„ ๋ฐฐ์šด๋‹ค. ๋˜ํ•œ GROUP BY๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง€์ •ํ•œ ์—ด์˜ ๋ฐ์ดํ„ฐ๋“ค์„ ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ผ๋ฆฌ๋Š” ๋ฌถ์–ด์„œ ๊ฒฐ๊ณผ๋ฅผ ์ถ”์ถœํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. ์ฃผ๋กœ ํ•ฉ๊ณ„, ํ‰๊ท , ๊ฐœ์ˆ˜ ๋“ฑ์„ ์ฒ˜๋ฆฌํ•˜๋ฏ€๋กœ ์ง‘๊ณ„ํ•จ์ˆ˜์™€ ๊ฐ™์ด ์“ฐ์ด๊ณ  HAVING ์ ˆ์„ ํ†ตํ•ด ์กฐ๊ฑด์‹์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. ORDER BY ์ ˆ ๋จผ์ € ๊ธฐ๋ณธ์ ์ธ SELECT ์ ˆ์˜ ํ˜•์‹์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค. SELECT ์—ด_์ด๋ฆ„ FROM ํ…Œ์ด๋ธ”_์ด๋ฆ„ WHERE ์กฐ๊ฑด์‹ GROUP BY ์—ด_์ด๋ฆ„ HAVING ์กฐ๊ฑด์‹ ORDER BY ์—ด_์ด๋ฆ„ -- ** LIMIT ์ˆซ์ž -- ** member ๋ฐ์ดํ„ฐ์—์„œ ๋ฐ๋ท”์ผ์ž๊ฐ€ ๋น ๋ฅธ ์ˆœ์œผ๋กœ mem_id, mem_n..

Study/SQL 2022. 1. 10. 18:20