SQL - UPPER(), ROWER()
ยท
DB/SQL
๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜ ํ•จ์ˆ˜ ์˜ˆ์ œ https://programmers.co.kr/learn/courses/30/lessons/59047 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ด๋ฆ„์— el์ด ๋“ค์–ด๊ฐ€๋Š” ๋™๋ฌผ ์ฐพ๊ธฐ ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋”” programmers.co.kr SELECT ANIMAL_ID, NAME FROM ANIMAL_INS WHERE ANIMAL_TYPE = 'Dog' AND UPPER(NAME) LIKE '%EL%' ORDER BY NAME
SQL - ์—ฐ์‚ฐ์ž IN
ยท
DB/SQL
ํŠน์ • ์นผ๋Ÿผ์˜ ๊ฐ’์ด ์ฃผ์–ด์ง„ ๊ฐ’ ์ง‘ํ•ฉ์— ์†ํ•˜๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒ€์‚ฌ ์˜ˆ์ œ https://programmers.co.kr/learn/courses/30/lessons/59046 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ฃจ์‹œ์™€ ์—˜๋ผ ์ฐพ๊ธฐ ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋”” programmers.co.kr SELECT ANIMAL_ID, NAME, SEX_UPON_INTAKE FROM ANIMAL_INS WHERE NAME IN ('Lucy', 'Ella', 'Pickle', 'Rogan', ..
SQL - JOIN
ยท
DB/SQL
JOIN์˜ ์ข…๋ฅ˜ Cartesian Product(๊ณฑ์ง‘ํ•ฉ) : ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฒฐํ•ฉํ•จ. Equi-join : ๊ฐ ํ…Œ์ด๋ธ”์—์„œ ํ•˜๋‚˜์”ฉ ์นผ๋Ÿผ์„ ์„ ํƒํ•˜์—ฌ ๊ทธ ๊ฐ’๋“ค์ด ๊ฐ™์€ ํ–‰๋“ค๋งŒ ์„œ๋กœ ์—ฐ๊ฒฐ์‹œํ‚ด. Non-Equi-join : ๋™๋“ฑ ๋น„๊ต ์™ธ์˜ ๋‹ค๋ฅธ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ. Self-join : ์ž๊ธฐ ์ž์‹ ๊ณผ ์กฐ์ธ ์ˆ˜ํ–‰. Outer Join : ์กฐ์ธ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜์ง€ ์•Š๋Š” ํ–‰๋“ค๋„ ๊ฒฐ๊ณผ์— ํฌํ•จ์‹œํ‚ด. - left, right ์˜ˆ์ œ Outer Join https://programmers.co.kr/learn/courses/30/lessons/59042 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์—†์–ด์ง„ ๊ธฐ๋ก ์ฐพ๊ธฐ ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_..
SQL - NVL()
ยท
DB/SQL
NVL ํ•จ์ˆ˜ NVL(์นผ๋Ÿผ๋ช… , "์ง€์ •๊ฐ’") : ๊ฐ’์ด NULL์ธ ๊ฒฝ์šฐ ์ง€์ •๊ฐ’์„ ์ถœ๋ ฅํ•˜๊ณ , NULL์ด ์•„๋‹ˆ๋ฉด ์›๋ž˜ ๊ฐ’์„ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•œ๋‹ค. ์˜ˆ์ œ https://programmers.co.kr/learn/courses/30/lessons/59410 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - NULL ์ฒ˜๋ฆฌํ•˜๊ธฐ ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋”” programmers.co.kr Oracle SELECT ANIMAL_TYPE, NVL(NAME, 'No name'), SEX_UPON_INTAK..
SQL - HAVING
ยท
DB/SQL
https://programmers.co.kr/learn/courses/30/lessons/59041 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋™๋ช… ๋™๋ฌผ ์ˆ˜ ์ฐพ๊ธฐ ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋”” programmers.co.kr oracle SELECT NAME, COUNT(NAME) FROM ANIMAL_INS GROUP BY NAME HAVING COUNT(NAME) >= 2 ORDER BY NAME https://programmers.co.kr/learn/courses/..
SQL - ์ง‘๊ณ„ ํ•จ์ˆ˜
ยท
DB/SQL
MAX() MIN() COUNT() & DISTINCT DISTINCT : ์ค‘๋ณต๊ฐ’ ์ œ์™ธํ•˜๊ณ  ์นด์šดํŠธ ์œ ์˜ํ•  ์  - DISTINCT ์œ„์น˜ --์ด๋ฆ„์˜ ์ค‘๋ณต์„ ๋จผ์ € ์ œ๊ฑฐํ•œ๋’ค, ๊ฐฏ์ˆ˜๋ฅผ ์…ˆ SELECT COUNT(DISTINCT NAME) FROM ANIMAL_INS --์ด๋ฆ„์˜ ๊ฐฏ์ˆ˜๋ฅผ ์ค‘๋ณต์ œ๊ฑฐํ•˜๋Š” ํ–‰์œ„ SELECT DISTINCT COUNT(NAME) FROM ANIMAL_INS + count ํ•จ์ˆ˜๋Š” NULL์„ ์„ธ์ง€ ์•Š๊ธฐ ๋–„๋ฌธ์—, ๊ตณ์ด WHERE NAME IS NOT NULL์„ ์“ฐ์ง€ ์•Š์•„๋„ ๋œ๋‹ค. SUM() AVG()
giraffe_
'DB' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)