Growth ๐ŸŒณ/Practice ๐Ÿ’ป

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๊ทธ๋ฃน๋ณ„ ์กฐ๊ฑด์— ๋งž๋Š” ์‹๋‹น ๋ชฉ๋ก ์ถœ๋ ฅํ•˜๊ธฐ (2์ฐจ ํ’€์ด)

์ธ” 2023. 1. 12. 13:32

 

๐Ÿ“ข ๋ณธ ํฌ์ŠคํŒ…์€ Growth/Practice ๊ฒŒ์‹œ๊ธ€ (https://sy038680.tistory.com/241 )๋ฌธ์ œ์— ๋Œ€ํ•œ 2์ฐจ ํ’€์ด์ž…๋‹ˆ๋‹ค.

 


๊ธฐ์กด ํ’€์ด์—์„œ๋Š” WHERE์ ˆ ๋‚ด ์„œ๋ธŒ์ฟผ๋ฆฌ๊นŒ์ง€ JOIN์„ ์‚ฌ์šฉํ•œ ํ…Œ์ด๋ธ”์—์„œ ์ฟผ๋ฆฌ๋ฅผ ์ถ”์ถœํ–ˆ๋Š”๋ฐ

๋‹ค์‹œ ํ’€์–ด๋ณด๋ฉด์„œ WHERE์ ˆ ์ปฌ๋Ÿผ ์กฐ๊ฑด์„ MEMBER_NAME์ด ์•„๋‹Œ MEMBER_ID๋กœ ์žก์•„์ฃผ๋ฉด ์กฐ์ธ ์—†์ด REST_REVIEWํ…Œ์ด๋ธ”์—์„œ ๋ฆฌ๋ทฐ๋ฅผ ๊ฐ€์žฅ ๋งŽ์ด ์ž‘์„ฑํ•œ ํšŒ์›์˜ ์•„์ด๋””๋ฅผ ์กฐ๊ฑด์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

SELECT MP.MEMBER_NAME, RR.REVIEW_TEXT, 
DATE_FORMAT(RR.REVIEW_DATE, '%Y-%m-%d') REVIEW_DATE
 FROM MEMBER_PROFILE MP
 INNER JOIN REST_REVIEW RR
 ON MP.MEMBER_ID = RR.MEMBER_ID
 WHERE RR.MEMBER_ID = (SELECT MEMBER_ID
                       FROM REST_REVIEW
                       GROUP BY 1
                       ORDER BY COUNT(*) DESC
                       LIMIT 1)
 ORDER BY 3, 2

 


๐Ÿ“  

ํ…Œ์ด๋ธ” ์กฐ์ธ์ด ํ•„์š”ํ•œ ์ƒํ™ฉ์—์„œ

๋ฉ”์ธ SELECT์ ˆ์—์„œ ์ตœ๋Œ€๊ฐ’์ด๋‚˜ ์ตœ์†Œ๊ฐ’ ๋˜๋Š” ํŠน์ •๊ฐ’๋งŒ์„ ์ถœ๋ ฅํ•ด์•ผํ•œ๋‹ค๋ฉด

๊ณตํ†ต ์ปฌ๋Ÿผ๋ถ€ํ„ฐ ์ƒ๊ฐํ•ด๋ณธ๋‹ค๋ฉด ๋น ๋ฅธ ํ’€์ด๊ฐ€ ๊ฐ€๋Šฅํ•  ๊ฒƒ ๊ฐ™๋‹ค.