๐Ÿฅ‘ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค SQL ๊ณ ๋“์  Kit [SUM, MAX, MIN]

์œค๊ฑดํฌ(Guny)ยท2020๋…„ 10์›” 15์ผ
0

Database

๋ชฉ๋ก ๋ณด๊ธฐ
3/7
post-thumbnail
post-custom-banner

SQL ๊ณ ๋“์  Kit - SUM, MAX, MIN

๐Ÿ“š๋‚˜์ด๊ฐ€ ๊ฐ€์žฅ ๋งŽ์€ ์‚ฌ๋žŒ์€ ๋ˆ„๊ตฌ์ผ๊นŒ? ํ…Œ์ด๋ธ”์„ ๋’ค์ ธ ํ†ต๊ณ„๋ฅผ ๋‚ด์–ด๋ด…์‹œ๋‹ค.


โœ…์ตœ๋Œ“๊ฐ’ ๊ตฌํ•˜๊ธฐ

๊ฐ€์žฅ ์ตœ๊ทผ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์€ ์–ธ์ œ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.

SELECT MAX(DATETIME)
FROM ANIMAL_INS


โœ…์ตœ์†Ÿ๊ฐ’ ๊ตฌํ•˜๊ธฐ

๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๊ฐ€์žฅ ๋จผ์ € ๋“ค์–ด์˜จ ๋™๋ฌผ์€ ์–ธ์ œ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.

SSELECT MIN(DATETIME)
FROM ANIMAL_INS


โœ…๋™๋ฌผ ์ˆ˜ ๊ตฌํ•˜๊ธฐ

๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋™๋ฌผ์ด ๋ช‡ ๋งˆ๋ฆฌ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.

SELECT COUNT(ANIMAL_ID)
FROM ANIMAL_INS


โœ…์ค‘๋ณต ์ œ๊ฑฐํ•˜๊ธฐ

๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ด๋ฆ„์€ ๋ช‡ ๊ฐœ์ธ์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์ด๋•Œ ์ด๋ฆ„์ด NULL์ธ ๊ฒฝ์šฐ๋Š” ์ง‘๊ณ„ํ•˜์ง€ ์•Š์œผ๋ฉฐ ์ค‘๋ณต๋˜๋Š” ์ด๋ฆ„์€ ํ•˜๋‚˜๋กœ ์นฉ๋‹ˆ๋‹ค.

SELECT COUNT(DISTINCT NAME) count
FROM ANIMAL_INS

profile
๊ฐœ๋ฐœ์ž
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€