코드잇/데이터베이스

SQL 백문이 불여일타

양상추상츄 2023. 2. 5. 01:23

데이터특성 구성하기

SELECT COUNT(*) FROM copang_main.member;
SELECT COUNT(email) FROM copang_main.member;
SELECT MIN(weight) FROM copang_main.member;
SELECT MAX(weight) FROM copang_main.member;
SELECT AVG(weight) FROM copang_main.member;
SELECT SUM(age) FROM copang_main.member;
SELECT STD(age) FROM copang_main.member; -- 표준편차
SELECT CEIL(height) FROM copang_main.member; -- 올림함수
SELECT FLOOR(height) FROM copang_main.member; -- 내림함수
SELECT ROUND(height) FROM copang_main.member; --반올림 함수
-- NULL이 아닌 값 찾기
SELECT * FROM copang_main.member WHERE address IS NOT NULL;

-- NULL인 값을 찾기
SELECT * FROM copang_main.member
WHERE height IS NULL
    OR wheight IS NULL
    OR address IS NULL;

-- NULL인 값을 변경하기
SELECT 
    COALESCE(height, '###'),
    COALESCE(wheight, '---'),
    COALESCE(address, '@@@')
FROM copang_main.member;