๋ชฉ๋กMin (1)

suvera-dev ๐Ÿฅฆ

SQL) ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค SQL ๊ณ ๋“์  Kit - SUM, MIN, MAX

1. ์ตœ๋Œ“๊ฐ’ ๊ตฌํ•˜๊ธฐ ๊ฐ€์žฅ ์ตœ๊ทผ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์€ ์–ธ์ œ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. => ๊ฐ€์žฅ ์ตœ๊ทผ์— ๋“ค์–ด์™”์„ ๊ฒฝ์šฐ, Datetime์ด ์ œ์ผ ํผ SELECT MAX(DATETIME) FROM ANIMAL_INS LIMIT 1; 2. ์ตœ์†Ÿ๊ฐ’ ๊ตฌํ•˜๊ธฐ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๊ฐ€์žฅ ๋จผ์ € ๋“ค์–ด์˜จ ๋™๋ฌผ์€ ์–ธ์ œ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. SELECT MIN(DATETIME) FROM ANIMAL_INS LIMIT 1; 3. ๋™๋ฌผ ์ˆ˜ ๊ตฌํ•˜๊ธฐ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋™๋ฌผ์ด ๋ช‡ ๋งˆ๋ฆฌ ๋“ค์–ด์™”๋Š”์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. SELECT COUNT(*) FROM ANIMAL_INS 4. ์ค‘๋ณต ์ œ๊ฑฐํ•˜๊ธฐ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ด๋ฆ„์€ ๋ช‡ ๊ฐœ์ธ์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์ด๋•Œ ์ด๋ฆ„์ด NULL..

Algorithm/CodingTest - SQL 2022. 4. 15. 03:19