티스토리 뷰
집계 함수
CREATE TABLE myRecode(
recodeID int(10) unsigned auto_increment,
memberID int(10) unsigned,
javascript tinyint NOT NULL,
html tinyint NOT NULL,
css tinyint NOT NULL,
mysql tinyint NOT NULL,
react tinyint NOT NULL,
PRIMARY KEY (recodeID)
) charset=utf8;
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(1, 50, 30, 40, 30, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(2, 40, 10, 20, 10, 20);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(3, 50, 70, 60, 50, 30);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(4, 60, 40, 50, 70, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(5, 70, 60, 40, 30, 20);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(6, 80, 30, 60, 30, 30);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(7, 90, 30, 40, 50, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(8, 10, 90, 40, 10, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(9, 10, 20, 40, 40, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(10, 30, 10, 90, 70, 60);
집계함수의 종류
SELECT count(javascript) FROM myRecode;
SELECT sum(javascript) FROM myRecode;
SELECT avg(javascript) FROM myRecode;
SELECT max(javascript) FROM myRecode;
SELECT min(javascript) FROM myRecode;
그룹별 집계
GROUP BY
SELECT 필드명 FROM 테이블명 GROUP BY 필드명
SELECT count(javascript) FROM myRecode;
'MySQL' 카테고리의 다른 글
[MySQL] 테이블 합치기 (0) | 2022.04.14 |
---|---|
[MySQL] 테이블 데이터 - 데이터 수정하기 & 삭제하기 (0) | 2022.04.14 |
[MySQL] 테이블 데이터 - 데이터 입력하기 & 불러오기 (0) | 2022.04.14 |
[MySQL] 테이블 수정 (0) | 2022.04.14 |
[MySQL] 테이블 제어 (0) | 2022.04.08 |
댓글
© 2018 webstoryboy