Banner

My Tech Blog (์ฝ”๋“œ)

๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…๐Ÿ˜‰ 2. ๋ฌธ์ œ ์š”์•ฝ๋ฌธ์ œ์—์„œ ์ฃผ์–ด์ง„ ์กฐ๊ฑดPATIENTDOCTORAPPOINTMENTํ™˜์ž ์ •๋ณด์˜์‚ฌ ์ •๋ณด์ง„๋ฃŒ ์˜ˆ์•ฝ ๋ชฉ๋กPT_NO, PT_NAME, GEND_CD, AGE, TLNODR_NAME, DR_ID, LCNS_NO, HIRE_YMD, MCDP_CD, TLNOAPNT_YMD, APNT_NO, PT_NO, MCDP_CD, MDDR_ID, APNT_CNCL_YN, APNT_CNCL_YMDํ™˜์ž๋ฒˆํ˜ธ, ํ™˜์ž์ด๋ฆ„, ์„ฑ๋ณ„์ฝ”๋“œ, ๋‚˜์ด, ์ „ํ™”๋ฒˆํ˜ธ์˜์‚ฌ์ด๋ฆ„, ์˜์‚ฌID, ๋ฉดํ—ˆ๋ฒˆํ˜ธ, ๊ณ ์šฉ์ผ์ž, ์ง„๋ฃŒ๊ณผ์ฝ”๋“œ, ์ „ํ™”๋ฒˆํ˜ธ์ง„๋ฃŒ ์˜ˆ์•ฝ์ผ์‹œ, ์ง„๋ฃŒ์˜ˆ์•ฝ๋ฒˆํ˜ธ, ํ™˜์ž๋ฒˆํ˜ธ, ์ง„๋ฃŒ๊ณผ์ฝ”๋“œ, ์˜์‚ฌID, ์˜ˆ์•ฝ์ทจ์†Œ์—ฌ๋ถ€, ์˜ˆ์•ฝ์ทจ์†Œ๋‚ ์งœ ๋ฌธ์ œ์ชผ๊ฐœ๊ธฐโœ… 2022๋…„ 4์›” 13์ผ AP.APNT_YMD LIKE '2022-04-13%'โœ… ์ทจ์†Œ๋˜์ง€ ์•Š์€..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โœ๏ธ 2. ๋ฌธ์ œ ์š”์•ฝ๋ฌธ์ œ์—์„œ ์ฃผ์–ด์ง„ ์กฐ๊ฑดCAR_RENTAL_COMPANY_CAR CAR_RENTAL_COMPANY_RENTAL_HISTORY CAR_RENTAL_COMPANY_DISCOUNT_PLAN๋Œ€์—ฌ ์ค‘์ธ ์ž๋™์ฐจ๋“ค์˜ ์ •๋ณด์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ์ •๋ณด์ž๋™์ฐจ ์ข…๋ฅ˜ ๋ณ„ ๋Œ€์—ฌ ๊ธฐ๊ฐ„ ์ข…๋ฅ˜ ๋ณ„ ํ• ์ธ ์ •์ฑ… ์ •๋ณดCAR_ID, CAR_TYPE, DAILY_FEE, OPTIONSHISTORY_ID, CAR_ID, START_DATE, END_DATEPLAN_ID, CAR_TYPE, DURATION_TYPE, DISCOUNT_RATE- ์ž๋™์ฐจ ID,- ์ž๋™์ฐจ ์ข…๋ฅ˜,- ์ผ์ผ ๋Œ€์—ฌ ์š”๊ธˆ(์›),- ์ž๋™์ฐจ ์˜ต์…˜ ๋ฆฌ์ŠคํŠธ,- ์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ID,- ์ž๋™์ฐจ ID- ๋Œ€์—ฌ ์‹œ์ž‘์ผ, - ๋Œ€์—ฌ ์ข…๋ฃŒ์ผ- ์š”๊ธˆ ํ• ์ธ ์ •์ฑ… ID,..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โญ 2. ์ •๋‹ต์ฝ”๋“œ๋‚ด๊ฐ€ ํ‘ผ ์ฝ”๋“œ ORDER BY DATEDIFF (์ž…์†Œ์ผ, ํ‡ด์†Œ์ผ)SELECT I.ANIMAL_ID, I.NAMEFROM ANIMAL_INS I JOIN ANIMAL_OUTS O ON I.Animal_id = O.Animal_idORDER BY DATEDIFF(I.DATETIME, O.DATETIME)LIMIT 2์ด๋ ‡๊ฒŒ ํ•ด์„œ ์ •๋‹ต์ฒ˜๋ฆฌ๊ฐ€ ๋ฌ๋Š”๋ฐ ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ์“ด ์ฝ”๋“œ๋ฅผ ๋ณด๋‹ค๊ฐ€ ๋ญ”๊ฐ€ ์ด์ƒํ•œ ์  ๋ฐœ๊ฒฌ!๋ณดํ˜ธ์†Œ ํ‡ด์†Œ์ผ - ์ž…์†Œ์ผ ์„ ํ•ด์„œ ๊ทธ ๊ฐ’์ด ํฐ ์ˆœ์„œ๋Œ€๋กœ 2๊ฑด์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฑด๋ฐ๋‚˜๋Š” ์ž…์†Œ์ผ - ํ‡ด์†Œ์ผ๋กœ ๋ฐ˜๋Œ€๋กœ ์ ์—ˆ๋‹ค ๋Œ€์‹  ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ํ•˜๋‹ˆ๊นŒ ์ž‘๋™ํ•œ๋‹ค.๐Ÿฆ 3. ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ํ‘ผ ์ฝ”๋“œORDER BY DATEDIFF (ํ‡ด์†Œ์ผ, ์ž…์†Œ์ผ) DESCSELECT I.ANIMAL_ID, I.N..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โŒ 2. ์‹คํŒจํ•œ ์ฝ”๋“œ PRODUCT_CODE ์ปฌ๋Ÿผ์ด ์˜ˆ๋ฅผ ๋“ค๋ฉด 'A1000011' ์ด๊ธฐ ๋•Œ๋ฌธ์—SUBSTRING(์ปฌ๋Ÿผ๋ช…,์‹œ์ž‘์ธ๋ฑ์Šค,๋์ธ๋ฑ์Šค)๋กœ ์•ž ๋‘ ์ž๋ฆฌ๋งŒ ๋–ผ์–ด ๋‚ด์•ผ ํ•œ๋‹ค. SELECT SUBSTRING(Product_code,1,2) AS CATEGORY, COUNT(SUBSTRING(Product_code,1,2)) AS PRODUCTSFROM PRODUCTGROUP BY SUBSTRING(Product_code,1,2), Product_codeORDER BY Category; ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ์˜ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด A2 ๊ธฐ์ค€์œผ๋กœ GROUP ์œผ๋กœ ๋ฌถ์ด์ง€ ์•Š์€ ๊ฒƒ์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.โญ 3. ์ •๋‹ต์ฝ”๋“œGROUP BY ์ ˆ์—์„œ SUBSTRING(Product_code,1,2)๋กœ๋งŒ ๋ฌถ์–ด์•ผ ํ•จP..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โŒ 2. ์‹คํŒจํ•œ ์‹œ๋„SELECT CASE WHEN SUBSTRING(DIFFERENTIATION_DATE, 6,7) IN ('01', '02', '03') THEN '1Q' WHEN SUBSTRING(DIFFERENTIATION_DATE, 6,7) IN ('04', '05', '06') THEN '2Q' WHEN SUBSTRING(DIFFERENTIATION_DATE, 6,7) IN ('07', '08', '09') THEN '3Q' WHEN SUBSTRING(DIFFERENTIATION_DATE, 6,7) IN ('10', '11', '12') THEN '4Q' END AS QUARTER, COUNT(..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…๐Ÿ’ก 2. ์ ‘๊ทผ๋ฐฉ์‹๋™์ ๊ณ„ํš๋ฒ•(Dynamic Programming)์ด๋ž€?๋™์  ๊ณ„ํš๋ฒ•์„ ์•„์ฃผ ์‰ฝ๊ฒŒ ์„ค๋ช…ํ•˜์ž๋ฉด, '์ด๋ฏธ ๊ณ„์‚ฐํ•œ ๊ฑด ๊ธฐ์–ตํ•ด ๋‘์—ˆ๋‹ค๊ฐ€, ๋‹ค์‹œ ํ•˜์ง€ ๋ง์ž'๋Š” ์ „๋žต์ด๋‹ค.๋™์  ๊ณ„ํš๋ฒ•(Dynamic Programming, DP)์€ ๋ณต์žกํ•œ ๋ฌธ์ œ๋ฅผ ์ž‘์€ ํ•˜์œ„ ๋ฌธ์ œ๋กœ ๋‚˜๋ˆ„์–ด ํ•ด๊ฒฐํ•˜๊ณ , ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•˜์—ฌ ๋™์ผํ•œ ํ•˜์œ„ ๋ฌธ์ œ๋ฅผ ๋‹ค์‹œ ๊ณ„์‚ฐํ•˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์„ค๊ณ„ ๊ธฐ๋ฒ•์ด๋‹ค. ์ฃผ๋กœ ์ตœ์ ํ™” ๋ฌธ์ œ๋‚˜ ์กฐํ•ฉ ๋ฌธ์ œ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ํ•ด๊ฒฐํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. ๋™์  ๊ณ„ํš๋ฒ•์—๋Š” Top-Down ๋ฐฉ์‹์ธ ๋ฉ”๋ชจ์ด์ œ์ด์…˜๊ณผ Bottom-Up ๋ฐฉ์‹์ธ ํ…Œ์ด๋ธ”๋ง์ด ์žˆ๋‹ค.  Top-Down (๋ฉ”๋ชจ์ด์ œ์ด์…˜)์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ. ํ•˜์œ„ ๋ฌธ์ œ์˜ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•˜์—ฌ ์ค‘๋ณต ๊ณ„์‚ฐ ๋ฐฉ์ง€Bottom-Up (ํ…Œ์ด๋ธ”๋ง)์ž‘์€ ๋ฌธ์ œ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ํ•ด๊ฒฐ..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โŒ 2. ์‹คํŒจํ•œ ์‹œ๋„SELECT U.User_id, U.Nickname, CONCAT(U.City,' ', U.Street_address1, ' ', U.Street_address2) AS ์ „์ฒด์ฃผ์†Œ, CONCAT(SUBSTR(TLNO, 1, 3), '-', SUBSTR(TLNO, 4, 4), '-', SUBSTR(TLNO, 8)) AS ์ „ํ™”๋ฒˆํ˜ธFROM Used_goods_board B JOIN Used_goods_user U ON B.Writer_id = U.User_idHAVING COUNT(BOARD_ID) >= 3ORDER BY U.User_id DESC; - CONCAT ํ•จ์ˆ˜๋Š” + ๊ฐ€ ์•„๋‹ˆ๋ผ , ๋ฅผ ์‚ฌ์šฉ..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…๐Ÿ’ก 2. ์ ‘๊ทผ๋ฐฉ์‹์ด ๋ฌธ์ œ๋Š” ๋„ˆ๋ฌด ์–ด๋ ค์›Œ์„œ ์Šค์Šค๋กœ ํ’€๊ธฐ ํž˜๋“ค์–ด์„œ ๊ฒ€์ƒ‰์˜ ๋„์›€์„ ๋ฐ›์Œ.์ฃผ์–ด์ง„ ๋ฌธ์ œ๋Š” ๊ทธ๋ž˜ํ”„ ์ด๋ก ์˜ ์ตœ์†Œ ์‹ ์žฅ ํŠธ๋ฆฌ(MST, Minimum Spanning Tree) ๋ฌธ์ œ์ด๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ’€๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ์ „์ œ์ง€์‹- Union-Find(์œ ๋‹ˆ์˜จ ํŒŒ์ธ๋“œ) ์ž๋ฃŒ๊ตฌ์กฐ- Kruskal's Algorithm (ํฌ๋ฃจ์Šค์นผ) ์•Œ๊ณ ๋ฆฌ์ฆ˜ Kruskal's Algorithm (ํฌ๋ฃจ์Šค์นผ ์•Œ๊ณ ๋ฆฌ์ฆ˜)ํฌ๋ฃจ์Šค์นผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์œ„์— ๋งํ•œ ์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ(MST)๋ฅผ ๊ตฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ๋ฌธ์ œ์˜ ๋ถ„๋ฅ˜ ๋‹ต๊ฒŒ greedy์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ๊ฒฐ์ •์˜ ์ˆœ๊ฐ„๋งˆ๋‹ค ์ตœ์„ ์˜ ๊ฒฐ์ •์„ ํ•จ์œผ๋กœ์„œ ์ตœ์ข…์ ์ธ ๋‹ต์„ ๊ตฌํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ชจ๋“  ์ •์ ์„ ์ตœ์†Œ ๋น„์šฉ์œผ๋กœ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค.ํฌ๋ฃจ์Šค์นผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ํ•ต์‹ฌ์€ ๋ชจ๋“  ๊ฐ„์„ ์„ ๊ฐ€์ค‘์น˜ ๊ธฐ์ค€(์—ฌ๊ธฐ์„œ๋Š” ๋‹ค๋ฆฌ ๊ฐœ์„ค..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'์ฝ”๋“œ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก
์ƒ๋‹จ์œผ๋กœ