Banner

My Tech Blog (๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ)

์‰ฌ์šด ๋ฌธ์ œ๋Š” ํ•œ ๋ฒˆ์— ๋‘ ์„ธ๊ฐœ์”ฉ ํฌ์ŠคํŒ… ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ์ด ๋ฌธ์ œ๋Š” ์ƒ๊ฐ ํ•ด ๋ณผ ์—ฌ์ง€๊ฐ€ ๋งŽ๊ธฐ ๋•Œ๋ฌธ์— ํ•˜๋‚˜๋งŒ ์˜ฌ๋ฆฐ๋‹ค.๋…ผ๋ž€์˜ ์—ฌ์ง€๊ฐ€ ์žˆ๊ณ  ๋งŽ์€ ์˜๋ฌธ์ด ์ œ๊ธฐ๋˜๋Š” ๋ฌธ์ œ์ธ๋ฐ ๊ฐ™์€ ๊ณ ๋ฏผ์„ ํ•˜์‹  ๋ถ„๋“ค๊ป˜ ์ด ๋ฌธ์ œ์™€ ๊ด€๋ จํ•ด์„œ ๋‚ด๊ฐ€ ์ƒ๊ฐํ•ด๋ณด๊ณ  ์กฐ์‚ฌํ•œ ๋‚ด์šฉ์„ ๊ณต์œ ๋ฅผ ํ•ด๋ณด๊ณ ์žํ•œ๋‹ค. ๋‚ด๊ฐ€ ๊ถ๊ธˆํ–ˆ๋˜ ์ ์€ ์•„๋ž˜ ๋‘ ๊ฐ€์ง€์˜€๋‹ค. - "LENGTH ์— NULL ๋งŒ ์žˆ๋Š” ๊ฒฝ์šฐ๋Š” ์—†์Šต๋‹ˆ๋‹ค"๋ผ๋Š” ์กฐ๊ฑด์€ ์™œ ํ•„์š”ํ•œ ๊ฒƒ์ธ๊ฐ€์š”?- ์™œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค 2๋งŒ ์‹คํŒจ๊ฐ€ ๋œจ๋Š” ๊ฒƒ์ธ๊ฐ€์š”? ๋‚ด์ง€ 10cm ์ดํ•˜์ธ๋ฐ ์™œ ์ •๋‹ต์ฝ”๋“œ์—์„œ๋Š” ` ์ด ํฌ์ŠคํŒ…์— ๋Œ€ํ•ด์„œ๋Š” ์œ„ ์งˆ๋ฌธ๋“ค์— ๋Œ€ํ•ด ๋ช…์พŒํ•œ ํ•ด๋‹ต์„ ํ•  ๊ฒƒ์ด๋‹ค์ฒซ๋ฒˆ์งธ ์งˆ๋ฌธ์€ ๋ฌธ์ œ๋ฅผ ์ž์„ธํžˆ ์ฝ๊ณ  ์ƒ๊ฐํ•ด๋ณด๋‹ˆ ๋‹ต์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๊ณ  ๋‘๋ฒˆ์งธ ์งˆ๋ฌธ์€ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ์„ค๋ช…์„ ์ฐธ๊ณ ํ–ˆ๋‹ค. ๐Ÿ  ์ž”์ฑ™์ด ์žก์€ ์ˆ˜ ๊ตฌํ•˜๊ธฐ LENGTH ์ปฌ๋Ÿผ์— NULL๊ฐ’์ด..
๐Ÿ“‘ ๋ชจ๋“  ๋ ˆ์ฝ”๋“œ ์กฐํšŒํ•˜๊ธฐ10์ดˆ์ปท ๋ฌธ์ œSELECT *FROM ANIMAL_INSORDER BY ANIMAL_ID; ๐Ÿฆ ์กฐ๊ฑด์— ๋งž๋Š” ํšŒ์›์ˆ˜ ๊ตฌํ•˜๊ธฐSELECT COUNT(*)FROM USER_INFOWHERE YEAR(JOINED) = '2021' AND AGE BETWEEN 20 AND 29;๐Ÿ’ป Python ๊ฐœ๋ฐœ์ž ์ฐพ๊ธฐ ๋ณดํ†ต ์Œฉ์ดˆ๋ณด๋“ค์ด ํ‘ธ๋Š” ๋ฐฉ๋ฒ•SELECT ID, EMAIL, FIRST_NAME, LAST_NAMEFROM DEVELOPER_INFOSWHERE SKILL_1 = 'Python' OR SKILL_2 = 'Python' OR SKILL_3 = 'Python'ORDER BY ID; ํ•œ ๋ฒˆ ์ƒ๊ฐ ํ•ด ๋ณด๊ณ  ํ’€๋ฉด ์ด๋ ‡๊ฒŒ ใ…Žใ…Žใ…ŽSELECT ID, EMAIL, FIRST_NAME, L..
๊ทธ๋™์•ˆ ๋ช‡ ๋ฒˆ ๋†€๋Ÿฌ๊ฐ„ ์ ์€ ์—†์—ˆ์ง€๋งŒ,๊ฐ€์žฅ ์ฆ๊ฑฐ์› ๋˜ ์‹œ๊ฐ„์„ ํ•จ๊ป˜ ํ–ˆ๋˜ ์นด๋ฉ”๋ผ ๐Ÿ“ท ์ด๊ฑฐ ์ด๋ชจํ‹ฐ์ฝ˜์ด๋ž‘ ๋น„์Šทํ•˜๊ฒŒ ์ƒ๊ฒจ์„œ ๋” ๊ท€์—ฌ์› ๋‹ค.์˜ค๋Š˜์€ ๋‹น๊ทผ๋งˆ์ผ“์œผ๋กœ ๊ฐ€๋Š”๋‚  :( ๋– ๋‚  ์‹œ๊ฐ„์ด์•ผ๋ฐ”์ด๋ฐ”์ด    ์šฐ๋ฆฌ์™€ ํ•จ๊ป˜ ๋ณด๋‚ธ ์‹œ๊ฐ„๋™์•ˆ ์ฐ์€ ์‚ฌ์ง„์€ 2000์ปท ๋ฏธ๋งŒํšŒ์‚ฌ๋‹ค๋‹ˆ๋ฉด์„œ ๋ฐ”๋น ์„œ ๋ง‰์ƒ ๋งŽ์ด ์“ฐ์ง€๋ฅผ ๋ชปํ–ˆ๋‹ค. ์‚ฌ์ง„์„ ์ข‹์•„ํ•˜๋Š” ์ƒˆ ์ฃผ์ธ์„ ๋งŒ๋‚˜์„œ์˜ค์ฒœ์žฅ ๋งŒ์žฅ, ๋ฉ‹์ง„ ๊ณณ์— ๊ฐ€์„œ ์•„๋ฆ„๋‹ค์šด ํ’๊ฒฝ์„ ๋‹ด์•˜์œผ๋ฉด๐ŸŒฑ ์ฆ๊ฑฐ์šด ์‹œ๊ฐ„์€ ์ˆœ๊ฐ„์ด์ง€๋งŒ์ •๋ง๋กœ, ์‚ฌ์ง„๊ณผ ์ถ”์–ต์€ ์˜ค๋ž˜ ์˜ค๋ž˜ ๋‚จ๋Š”๋‹ค.   ์นด๋ฉ”๋ผ๋กœ ์•Œ๋ผ๋ฐ๊ฐ€ ์ฐ์–ด์ค€ ์‚ฌ์ง„ ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ >  ๋‚ด๊ฐ€ ์–ด๋ฆด ๋•Œ๋Š”, ๋””์ง€ํ„ธ ์นด๋ฉ”๋ผ๊ฐ€ ํฐ ์นด๋ฉ”๋ผ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ์›”๋“ฑ์ด ์šฐ์ˆ˜ํ–ˆ๋‹ค.๊ทธ๋Ÿฌ๋‚˜ ์ด์ œ๋Š” ํฐ์นด๋ฉ”๋ผ๋„ ์„ฑ๋Šฅ์ด ๋„ˆ๋ฌด๋„ˆ๋ฌด ์ข‹์•„์กŒ๋‹ค.๊ทธ๋ž˜๋„ ์ง„์งœ ์นด๋ฉ”๋ผ๊ฐ€ ํŠน๋ณ„ํ•œ ์ด์œ ๋Š” ๊ฐ์„ฑ ๋•Œ๋ฌธ์ธ ๊ฑฐ ๊ฐ™์˜ค :)  ์นด๋ฉ”๋ผ๋Š” ๋‹จ์ˆœํžˆ ์‚ฌ์ง„์„ ์ฐ๋Š” ๋„๊ตฌ..
๐Ÿ“š์กฐ๊ฑด์— ๋งž๋Š” ๋„์„œ ๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅํ•˜๊ธฐ ์•„๋ž˜๋Š” ์ •๋‹ต์ฒ˜๋ฆฌ ๋˜๋Š” ๋ชจ๋‘ ๋™์ผํ•œ ์ฝ”๋“œ์ด๋‹ค BETWEEN ์—ฐ์‚ฐ์ž๋กœ ํ’€๊ธฐSELECT BOOK_ID, DATE_FORMAT(PUBLISHED_DATE, '%Y-%m-%d') AS PUBLISHED_DATEFROM BOOKWHERE PUBLISHED_DATE BETWEEN '20210101' AND '20211231' AND CATEGORY LIKE '์ธ๋ฌธ'ORDER BY PUBLISHED_DATE; โญโญโญYEAR() ํ•จ์ˆ˜๋กœ ํ’€๊ธฐ (์ œ์ผ ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ)SELECT BOOK_ID, DATE_FORMAT(PUBLISHED_DATE, '%Y-%m-%d') AS PUBLISHED_DATEFROM BOOKWHERE YEAR(PUBLISHED_DATE) = 2021 ..
๐Ÿฆ ์ธ๊ธฐ ์žˆ๋Š” ์•„์ด์Šคํฌ๋ฆผ ๋„ˆ๋ฌด ์‰ฌ์›Œ์„œ ์„ค๋ช…ํ•  ๊ฒƒ๋„ ์—†๋‹ค...SELECT FLAVORFROM FIRST_HALFORDER BY TOTAL_ORDER DESC, SHIPMENT_ID; ๐Ÿญ ๊ฐ•์›๋„์— ์œ„์น˜ํ•œ ์ƒ์‚ฐ๊ณต์žฅ ๋ชฉ๋ก ์ถœ๋ ฅํ•˜๊ธฐSELECT FACTORY_ID, FACTORY_NAME, ADDRESSFROM FOOD_FACTORYWHERE ADDRESS LIKE '๊ฐ•์›๋„%'ORDER BY FACTORY_ID;๐Ÿ‘ฉ๐Ÿป‍๐Ÿ‘ง๐Ÿป‍๐Ÿ‘ง๐Ÿป 12์„ธ ์ดํ•˜์ธ ์—ฌ์ž ํ™˜์ž ๋ชฉ๋ก ์ถœ๋ ฅํ•˜๊ธฐ SELECT PT_NAME, PT_NO, GEND_CD, AGE, IFNULL(TLNO,'NONE') AS TLNOFROM PATIENTWHERE AGE  * SELECT์ ˆ์— ํ•จ์ˆ˜ ์ˆ˜ํ–‰ํ•˜๋ฉด ์ปฌ๋Ÿผ๋ช…์ด ํ•จ์ˆ˜๋ช…์œผ๋กœ ๋‚˜์˜ค๋ฏ€๋กœ ALIAS ๋ถ™์—ฌ์ฃผ๋Š”๊ฑฐ..
ยท Diary
๊ฐ€์„์˜ ๋์ž๋ฝ,,,๐Ÿ ๊ฐ€์„๋น„ ๋‚ด๋ฆฐ ๋’ค๋กœ ๋‚ ์”จ๊ฐ€ ์ œ๋ฒ• ์Œ€์Œ€ํ•ด์กŒ๋‹ค.์ฐฌ๋ฐ”๋žŒ์ด ์˜ท์ž๋ฝ ์‚ฌ์ด๋กœ ํŒŒ๊ณ  ๋“ค์–ด์™€์˜ท๊นƒ์„ ์—ฌ๋ฏธ๊ฒŒ ๋˜๋Š” ๊ทธ๋Ÿฐ ๋‚ ์”จ์˜€๋‹ค.... ๊ฒจ์šธ์ด ์„ฑํผ ๋‹ค๊ฐ€์˜ค๋Š” ๊ฒƒ ๊ฐ™๋‹ค.๐Ÿงฆ์‚ฌ๋žŒ๋“ค์˜ ๋จธ๋ฆฌ์œ„๋กœ ๋ˆˆ๋ฐœ์ด ํฌ๊ทผํ•˜๊ฒŒ ํฉ๋‚ ๋ฆฌ๋Š” ๊ฒจ์šธ๋‚ ์ด ๊ธฐ๋‹ค๋ ค์ง„๋‹ค >๋นจ๋ฆฌ ๋ˆˆ์ด ๋‚ด๋ ธ์œผ๋ฉด ์ข‹๊ฒ ๋‹ค.....ใ…‹ใ…‹ใ…‹ใ…‹   2024.11.17์˜ค๋Š˜์€ SQLD๋ณด๊ณ  ์˜จ ๋‚ ์‹œํ—˜ ๋ฌธ์ œ๋Š” ๋ฌด๋‚œํ•˜๊ฒŒ ๋‚˜์™”๋‹ค.์•ž์—๋Š” ๋งค์šฐ ์‰ฌ์› ๊ณ  ๋’ค๋กœ ๊ฐˆ์ˆ˜๋ก ์–ด๋ ค์›Œ์กŒ๋‹ค.์‹ค์ œ ์ฟผ๋ฆฌ๋ฌธ ๋ณด๋Š” ๊ฑด ์ž์‹ ์žˆ์—ˆ์ง€๋งŒ๊ฑฑ์ •ํ–ˆ๋˜ ๋ถ€๋ถ„์€ ์ด๋ก ๊ณผ๋ชฉ์ธ 1๊ณผ๋ชฉ์ด์—ˆ๋‹ค.10๋ฌธ์ œ ๋ฐ–์— ์•ˆ๋˜๋Š”๋ฐ ๋‚œํ•ดํ•ด์„œ ๊ณผ๋ฝ ๊ฑฑ์ •์ด ์žˆ์—ˆ๋Š”๋ฐ์ด๋ฒˆ์—๋Š” ์ •๋ง ์‰ฝ๊ฒŒ ๋‚˜์™”๋‹ค.  ์–ด๋ ค์› ๋˜๊ฑฐ ๋‘๋ฌธ์ œ๋ž‘ ํ—ท๊ฐˆ๋ฆฐ๊ฑฐ ํ•œ ๋ฌธ์ œ ์•„๋ž˜ ์ •๋ฆฌํ•ด ๋ณธ๋‹ค. ๋จผ์ €, ์ •๊ทœํ‘œํ˜„์‹ ๋ฌธ์ œ ๋„˜๋‚˜ ์–ด๋ ค์› ๋‹ค......`REGEXP_INSTR()`๋ณด๊ธฐ๊ฐ€ 4, 56, 78, ..
NATURAL JOIN์—๋Š” ON ์ ˆ ์“ธ ์ˆ˜ ์—†๋‹ค.SELECT A.COL1, B.COL2FROM SAMPLE1 A NATURAL JOIN SAMPLE BON A.COL1 = B.COL1  Oracle์˜ ๊ฒฝ์šฐ OUTER JOIN ์ž‘์„ฑ ์‹œ (+) ๊ธฐํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์ขŒ๋ณ€์ด๋‚˜ ์šฐ๋ณ€ ์ค‘ ํ•˜๋‚˜์—๋งŒ ํ‘œ๊ธฐํ•ด์•ผ ํ•œ๋‹ค.SELECT A.COL1, B.COL2FROM SAMPLE1 A, SAMPLE BWHERE A.COL1(+) = B.COL1(+); FULL OUTER JOIN์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” (+) ๊ธฐํ˜ธ ๋Œ€์‹  ํ‘œ์ค€ SQL ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Oracle 9i ์ดํ›„๋ถ€ํ„ฐ๋Š” ํ‘œ์ค€ SQL FULL OUTER JOIN ๊ตฌ๋ฌธ์„ ์ง€์›ํ•˜๋ฏ€๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:SELECT A.COL1, B.COL2FROM TA..
9์›”์— ์‹œํ—˜๋ณธ๊ฑฐ ๋‹น์—ฐํžˆ ํŒจ์Šค์ธ ์ค„ ์•Œ๊ณ  ๋ฃฐใ„น๋ž„๋ผ ์ง‘์— ์™”๋Š”๋ฐ2์  ์ฐจ์ด๋กœ ์ปคํŠธ๋ผ์ธ ๋ชป๋„˜๊ธด๊ณ  ์‹คํ™”์•ผ?์•„๋‹ˆ ์ด๊ฒŒ ๋ง์ด ๋ผ์•„...ใ…‹ใ…‹ใ…‹ใ…‹  ํ‚น๋ฐ›์•„..  * HAVING์ ˆ์€ SELECT ์ ˆ๋ณด๋‹ค ๋จผ์ € ์ˆ˜ํ–‰๋˜๋ฏ€๋กœ SELECT ์ ˆ์—์„œ ๊ธฐ์ˆ ๋œ ALIAS ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค๋Š”๊ฑฐ  ์—ด์‹ฌํžˆ ์‚ด์ž >์—ด์ • ์žˆ๊ฒŒ ์‚ด์ž ~~~ "๋‹น์‹ ์ด ์—ด์ •์„ ๊ฐ€์ง€๊ณ  ํ•˜๋Š” ์ผ์ด ์„ธ์ƒ์„ ๋ณ€ํ™”์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค๋ฉด, ๊ทธ ์ผ์€ ๊ฒฐ์ฝ” ํž˜๋“  ์ผ์ด ์•„๋‹ˆ๋‹ค."— ์Šคํ‹ฐ๋ธŒ ์žก์Šค (Steve Jobs)"์—ด์ •์€ ๋‹น์‹ ์˜ ๋ฏธ๋ž˜๋ฅผ ๋ฐํžˆ๋Š” ๋ถˆ๊ฝƒ์ด๋‹ค."— ์ต๋ช…"์„ฑ๊ณต์€ ์˜ค์ง ์—ด์ •๊ณผ ํ—Œ์‹ ์—์„œ ๋‚˜์˜จ๋‹ค."— ์•Œ๋ฒ„ํŠธ ์•„์ธ์Šˆํƒ€์ธ (Albert Einstein) "๋‹น์‹ ์ด ์ข‹์•„ํ•˜๋Š” ์ผ์„ ์ฐพ์œผ์„ธ์š”. ๊ทธ ์ผ์ด ๋‹น์‹ ์„ ์œ„ํ•ด ์กด์žฌํ•˜๋Š” ์ด์œ ์ž…๋‹ˆ๋‹ค."— ์˜คํ”„๋ผ ์œˆํ”„๋ฆฌ (Oprah Winfrey)"์—ด์ •์„ ๋Š๋ผ๋Š” ์ผ..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (13 Page)
์ƒ๋‹จ์œผ๋กœ