MySQL 기본 select SQL 예제
MySQL 기본 select SQL 예제
안녕하세요.
오늘은 MySQL에서 기본적으로 사용되는 select SQL의 예제를 보여드리고 사용법을 안내드리겠습니다.
우선 그전에 여기서 사용될 데이터들에 대해서 간략하게 안내하고, DDL문을 공유하겠습니다.
우선 이번 select SQL 예제 작성을 위해서 3개의 테이블을 생성할 것입니다.
student, exam_result, major 이렇게 3개의 테이블을 생성하고요.
각 테이블은 아래와 같은 성격의 데이터가 들어가게 됩니다.
student 테이블
student 테이블은 아래와 같이 생겼습니다.
학생 이름, 학번, 생년원일, 성별, 입학 연도, 전화번호, 학과 코드
총 66명의 학생 정보가 들어있습니다.
1. 테이블 DDL
create table student
(
name varchar(100) null comment '이름',
student_num varchar(11) null comment '학번',
birth_dt varchar(6) null comment '생년월일',
gender varchar(1) null comment '성별',
entrc_year varchar(4) null comment '입학년도',
mobile varchar(11) null comment '전화번호',
major_cd varchar(3) null comment '학과코드'
)
comment '학생정보' charset=utf8;
2. 데이터 insert 쿼리
데이터가 많은 관계로 접어 두겠습니다.
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('데미안', '16971504', '941112', 'M', '2016', '01010523220', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엘로이', '16945259', '930714', 'M', '2016', '01074494079', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('헨리', '16885578', '950603', 'M', '2016', '01073236179', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('안나', '16626786', '880816', 'F', '2016', '01098539654', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('루카스', '16543708', '950304', 'M', '2016', '01095544143', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('릴리', '15877030', '901215', 'F', '2015', '01065293405', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('루나', '15788253', '900908', 'F', '2015', '01086195344', '106');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('페뷔스', '15700939', '940316', 'M', '2015', '01097435136', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('카밀라', '15589962', '940619', 'F', '2015', '01012348900', '106');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('쥬리', '15578271', '950613', 'F', '2015', '01036724305', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('지나', '15309170', '901201', 'F', '2015', '01065692589', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('벤자민', '14939257', '900602', 'M', '2014', '01013155385', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('테드', '14885530', '940216', 'M', '2014', '01030037337', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엘리언', '14562369', '921015', 'M', '2014', '01019829629', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('테오', '14484171', '940315', 'M', '2014', '01034824739', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('앤디', '14362190', '940420', 'M', '2014', '01011193251', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('케드릭', '13949165', '950817', 'M', '2013', '01051881015', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('이안', '13753261', '920111', 'M', '2013', '01068381091', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('데이지', '13740398', '951023', 'F', '2013', '01011322531', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('이든', '13585677', '951022', 'M', '2013', '01091134045', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('헬리오', '13551644', '950716', 'M', '2013', '01074337853', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('로이드', '13550256', '870527', 'M', '2013', '01032421470', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제시카', '13500861', '881123', 'F', '2013', '01016400380', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제이', '12938335', '890102', 'M', '2012', '01071757377', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엘라', '12790181', '920916', 'F', '2012', '01063802062', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제레미', '12676231', '891015', 'M', '2012', '01013403272', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('셀레나', '12665540', '880317', 'F', '2012', '01085524698', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('네로', '12649105', '880213', 'M', '2012', '01015780578', '106');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제니', '12515986', '941015', 'F', '2012', '01034114041', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('메리', '11972722', '880821', 'F', '2011', '01047526572', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제이드', '11948285', '950227', 'M', '2011', '01083413212', '106');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('이시스', '11933250', '920621', 'F', '2011', '01098066965', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('루이', '11822923', '911108', 'M', '2011', '01013240679', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('카이', '11663197', '881109', 'M', '2011', '01078003753', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('알렉스', '11476583', '880715', 'M', '2011', '01084131154', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제이콥', '11459913', '910118', 'M', '2011', '01088494302', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('앤드류', '11337407', '921116', 'M', '2011', '01075919845', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('레이첼', '10998709', '951221', 'F', '2010', '01059763406', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엘렌', '10955111', '900810', 'F', '2010', '01011434540', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('마리아', '10893477', '930602', 'F', '2010', '01070951359', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('리안', '10804413', '930603', 'F', '2010', '01086189285', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('저스틴', '10617672', '900106', 'M', '2010', '01017910606', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엔젤라', '10615715', '871017', 'F', '2010', '01020461504', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('로미오', '10525777', '951218', 'M', '2010', '01026394815', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('세라', '10433607', '920215', 'F', '2010', '01094659677', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('루시', '10366365', '900121', 'F', '2010', '01048965286', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('도로시', '10284247', '871122', 'F', '2010', '01094513314', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('올리버', '10276637', '950723', 'M', '2010', '01075965847', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제이크', '09981340', '920217', 'M', '2009', '01067798684', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('테디', '09946130', '870523', 'M', '2009', '01075437977', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('레이나', '09839224', '940916', 'F', '2009', '01037190604', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('하니', '09791710', '881126', 'F', '2009', '01066181754', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('라이언', '09714111', '880510', 'M', '2009', '01027200637', '103');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('엘리', '09500575', '950208', 'F', '2009', '01033416716', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('겔런트', '09468667', '911023', 'M', '2009', '01051097227', '104');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제임스', '09374395', '880314', 'M', '2009', '01045999556', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('카일', '09286476', '931021', 'M', '2009', '01063095593', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('베시', '09243989', '910322', 'F', '2009', '01085797848', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('리암', '08980159', '920204', 'M', '2008', '01044885321', '106');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('레이', '08831906', '950408', 'M', '2008', '01021853474', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('제시', '08775794', '911209', 'F', '2008', '01094028708', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('루크', '08673644', '930919', 'M', '2008', '01053288396', '102');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('페비안', '08648751', '951008', 'M', '2008', '01050119141', '105');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('로이', '08506364', '911123', 'M', '2008', '01044349706', '101');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('로즈', '08405911', '890506', 'F', '2008', '01036932538', '100');
INSERT INTO class.student (name, student_num, birth_dt, gender, entrc_year, mobile, major_cd) VALUES ('라일라', '08235560', '911201', 'F', '2008', '01040435754', '103');
exam_result 테이블
exam_result 테이블은 아래와 같습니다.
학번, 시험 회차 (5회 차까지 존재), 수학 점수, 프로그래밍 점수, 영어점수가 들어있습니다.
참고로 모든 학생들이 모든 시험에 응시하진 않았습니다.
총 row 수는 284건입니다.
1. 테이블 DDL
create table exam_result
(
student_num varchar(11) null comment '학번',
exam_seq int null comment '시험회차',
math decimal(10,8) null comment '수학',
program decimal(10,8) null comment '프로그래밍',
english decimal(10,8) null comment '영어'
)
comment '시험성적' charset=utf8;
2. 데이터 insert 쿼리
데이터가 많은 관계로 접어 두겠습니다.
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09468667', 1, 4.33000000, 4.08000000, 2.23000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12649105', 1, 2.66000000, 2.93000000, 3.26000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16971504', 1, 2.42000000, 4.21000000, 2.43000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13740398', 1, 2.07000000, 2.66000000, 4.00000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10284247', 1, 4.29000000, 2.22000000, 3.99000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09714111', 1, 4.43000000, 2.34000000, 3.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08235560', 1, 2.92000000, 2.26000000, 4.39000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08831906', 1, 2.46000000, 3.78000000, 3.53000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09839224', 1, 2.67000000, 2.85000000, 2.92000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10998709', 1, 2.22000000, 4.23000000, 3.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10525777', 1, 4.38000000, 4.48000000, 2.93000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08506364', 1, 4.03000000, 3.82000000, 2.76000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13550256', 1, 4.23000000, 4.47000000, 4.14000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08405911', 1, 4.38000000, 3.63000000, 4.03000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15788253', 1, 3.18000000, 2.69000000, 2.35000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10366365', 1, 3.76000000, 4.23000000, 2.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11822923', 1, 2.36000000, 4.16000000, 4.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16543708', 1, 2.25000000, 3.63000000, 3.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08673644', 1, 3.75000000, 3.50000000, 4.16000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10804413', 1, 2.07000000, 4.22000000, 3.60000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08980159', 1, 4.47000000, 2.98000000, 4.46000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15877030', 1, 2.51000000, 3.84000000, 4.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10893477', 1, 3.79000000, 2.80000000, 2.66000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11972722', 1, 2.92000000, 3.02000000, 3.15000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09243989', 1, 2.68000000, 4.41000000, 4.07000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14939257', 1, 3.64000000, 2.38000000, 4.03000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10433607', 1, 3.00000000, 2.61000000, 3.94000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12665540', 1, 4.46000000, 3.49000000, 2.82000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16626786', 1, 2.84000000, 3.84000000, 3.80000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11476583', 1, 2.19000000, 3.48000000, 3.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11337407', 1, 2.22000000, 4.50000000, 4.44000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14362190', 1, 4.10000000, 2.18000000, 3.11000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10615715', 1, 2.01000000, 4.03000000, 2.16000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12790181', 1, 3.70000000, 4.19000000, 4.25000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10955111', 1, 2.97000000, 3.77000000, 4.26000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16945259', 1, 4.03000000, 4.45000000, 2.52000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09500575', 1, 4.17000000, 3.20000000, 3.32000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14562369', 1, 2.03000000, 3.47000000, 3.36000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10276637', 1, 3.56000000, 2.86000000, 4.07000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13585677', 1, 4.03000000, 3.67000000, 2.20000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11933250', 1, 3.88000000, 2.99000000, 3.57000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13753261', 1, 2.72000000, 4.42000000, 2.03000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10617672', 1, 4.24000000, 3.14000000, 3.03000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12515986', 1, 2.47000000, 4.21000000, 2.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12676231', 1, 3.98000000, 3.60000000, 2.48000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08775794', 1, 3.32000000, 2.15000000, 4.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13500861', 1, 3.10000000, 2.32000000, 2.79000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12938335', 1, 3.28000000, 2.77000000, 4.36000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11948285', 1, 2.99000000, 4.24000000, 2.59000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11459913', 1, 3.23000000, 4.36000000, 4.33000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09981340', 1, 2.09000000, 2.27000000, 4.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09374395', 1, 4.33000000, 2.73000000, 4.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15578271', 1, 3.12000000, 3.29000000, 4.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15309170', 1, 3.34000000, 2.07000000, 2.59000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15589962', 1, 2.81000000, 2.58000000, 4.24000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11663197', 1, 2.62000000, 2.79000000, 4.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09286476', 1, 3.49000000, 2.34000000, 2.52000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13949165', 1, 3.31000000, 3.77000000, 3.16000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14885530', 1, 3.31000000, 2.91000000, 2.67000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09946130', 1, 2.47000000, 2.23000000, 3.82000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14484171', 1, 2.52000000, 2.52000000, 2.94000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15700939', 1, 3.72000000, 2.27000000, 2.63000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08648751', 1, 4.13000000, 3.09000000, 4.25000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09791710', 1, 2.27000000, 4.14000000, 2.79000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16885578', 1, 4.18000000, 4.02000000, 3.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13551644', 1, 4.30000000, 4.07000000, 3.35000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16971504', 2, 3.82000000, 2.32000000, 4.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14362190', 2, 2.19000000, 4.31000000, 3.07000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13740398', 2, 3.01000000, 2.56000000, 4.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10955111', 2, 2.03000000, 2.04000000, 4.30000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15589962', 2, 2.60000000, 4.20000000, 3.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14939257', 2, 3.65000000, 2.16000000, 3.78000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11822923', 2, 4.14000000, 2.34000000, 2.80000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12676231', 2, 2.09000000, 2.64000000, 3.34000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12649105', 2, 3.86000000, 4.49000000, 2.55000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13500861', 2, 4.01000000, 4.01000000, 3.52000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10617672', 2, 2.02000000, 4.38000000, 2.98000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14562369', 2, 3.37000000, 3.86000000, 4.17000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10615715', 2, 2.21000000, 2.19000000, 3.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08831906', 2, 3.86000000, 2.65000000, 3.42000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10525777', 2, 2.41000000, 3.81000000, 2.52000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09714111', 2, 2.09000000, 4.36000000, 2.52000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14885530', 2, 4.00000000, 3.09000000, 2.99000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13550256', 2, 2.47000000, 4.03000000, 3.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09500575', 2, 4.45000000, 3.66000000, 4.17000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12515986', 2, 4.44000000, 4.35000000, 3.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14484171', 2, 4.50000000, 2.52000000, 3.77000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15578271', 2, 2.69000000, 2.68000000, 2.34000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08405911', 2, 2.17000000, 3.00000000, 4.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09839224', 2, 2.85000000, 2.07000000, 2.08000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08235560', 2, 2.61000000, 4.32000000, 3.64000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08506364', 2, 4.19000000, 2.62000000, 3.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08980159', 2, 2.56000000, 2.57000000, 4.19000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09374395', 2, 4.19000000, 2.76000000, 4.13000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11972722', 2, 4.10000000, 2.30000000, 3.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10366365', 2, 4.34000000, 4.32000000, 4.39000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08648751', 2, 3.26000000, 3.89000000, 4.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09468667', 2, 2.17000000, 4.12000000, 4.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13949165', 2, 2.67000000, 4.44000000, 3.44000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08673644', 2, 3.34000000, 2.72000000, 4.12000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10998709', 2, 4.20000000, 2.28000000, 3.96000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09286476', 2, 3.93000000, 4.35000000, 3.98000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12790181', 2, 2.55000000, 4.05000000, 2.32000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15877030', 2, 3.76000000, 4.38000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15309170', 2, 3.98000000, 2.57000000, 4.05000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09791710', 2, 2.64000000, 3.59000000, 4.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09981340', 2, 2.82000000, 3.10000000, 2.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13753261', 2, 2.82000000, 4.34000000, 3.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10893477', 2, 4.45000000, 4.24000000, 2.63000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12938335', 2, 4.22000000, 2.96000000, 2.13000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16885578', 2, 3.83000000, 3.42000000, 4.06000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13551644', 2, 2.84000000, 2.95000000, 4.01000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16945259', 2, 2.92000000, 2.27000000, 2.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09946130', 2, 4.43000000, 4.41000000, 4.12000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11337407', 2, 3.00000000, 4.32000000, 4.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10276637', 2, 3.19000000, 3.76000000, 2.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11663197', 2, 4.09000000, 2.54000000, 3.88000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11948285', 2, 4.01000000, 4.15000000, 2.79000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11476583', 2, 2.32000000, 4.39000000, 2.21000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12665540', 2, 2.05000000, 4.49000000, 4.33000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09243989', 2, 3.11000000, 2.00000000, 4.43000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14885530', 3, 3.84000000, 4.19000000, 3.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13550256', 3, 2.11000000, 2.34000000, 2.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09500575', 3, 2.54000000, 3.21000000, 2.01000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12515986', 3, 2.81000000, 2.94000000, 3.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14484171', 3, 3.72000000, 2.33000000, 3.75000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15578271', 3, 3.18000000, 4.36000000, 3.72000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08405911', 3, 2.43000000, 3.98000000, 2.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09839224', 3, 3.93000000, 4.06000000, 4.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08235560', 3, 2.37000000, 3.28000000, 4.23000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08506364', 3, 2.80000000, 4.25000000, 3.88000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08980159', 3, 4.50000000, 3.13000000, 2.45000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09374395', 3, 4.17000000, 3.93000000, 3.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11972722', 3, 3.30000000, 3.60000000, 4.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10366365', 3, 2.29000000, 2.16000000, 4.20000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08648751', 3, 2.43000000, 3.62000000, 3.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09468667', 3, 3.18000000, 2.28000000, 2.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13949165', 3, 3.05000000, 4.37000000, 3.44000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08673644', 3, 3.80000000, 3.23000000, 3.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10998709', 3, 2.00000000, 2.27000000, 4.15000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09286476', 3, 3.51000000, 3.79000000, 4.19000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12790181', 3, 3.82000000, 3.17000000, 4.36000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15877030', 3, 4.00000000, 2.11000000, 4.42000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15309170', 3, 2.47000000, 3.06000000, 2.95000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09791710', 3, 2.61000000, 4.18000000, 3.72000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09981340', 3, 2.04000000, 4.10000000, 2.67000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13753261', 3, 3.45000000, 4.23000000, 3.71000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10893477', 3, 4.42000000, 3.47000000, 4.27000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12938335', 3, 4.17000000, 3.44000000, 3.26000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16885578', 3, 3.47000000, 4.43000000, 2.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13551644', 3, 4.09000000, 2.16000000, 4.12000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16945259', 3, 3.48000000, 3.78000000, 4.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09946130', 3, 2.65000000, 3.35000000, 4.17000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11337407', 3, 2.61000000, 3.42000000, 2.51000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10276637', 3, 2.25000000, 2.56000000, 3.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11663197', 3, 2.41000000, 3.02000000, 2.77000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11948285', 3, 2.15000000, 4.20000000, 2.14000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11476583', 3, 2.62000000, 4.37000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12665540', 3, 4.32000000, 2.95000000, 4.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09243989', 3, 3.37000000, 2.46000000, 3.23000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10804413', 3, 3.60000000, 3.85000000, 2.01000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15788253', 3, 3.95000000, 3.72000000, 2.15000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11459913', 3, 4.24000000, 2.13000000, 4.07000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13585677', 3, 3.72000000, 4.38000000, 4.35000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08775794', 3, 3.44000000, 4.14000000, 4.35000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10284247', 3, 4.19000000, 2.52000000, 2.81000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10433607', 3, 2.38000000, 3.04000000, 3.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16543708', 3, 2.68000000, 2.68000000, 2.24000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15700939', 3, 2.68000000, 2.51000000, 4.11000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11933250', 3, 4.15000000, 3.81000000, 4.20000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16626786', 3, 4.36000000, 3.37000000, 4.15000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16971504', 4, 4.27000000, 2.87000000, 2.18000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16945259', 4, 3.62000000, 2.77000000, 3.73000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16885578', 4, 3.06000000, 2.55000000, 4.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16626786', 4, 4.29000000, 2.21000000, 3.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16543708', 4, 4.11000000, 3.35000000, 2.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15877030', 4, 3.34000000, 4.14000000, 4.01000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15788253', 4, 3.11000000, 3.43000000, 3.65000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15700939', 4, 3.22000000, 3.68000000, 3.79000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15589962', 4, 3.15000000, 4.04000000, 4.48000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15578271', 4, 2.42000000, 4.42000000, 4.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15309170', 4, 4.10000000, 4.28000000, 2.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14939257', 4, 2.25000000, 2.65000000, 3.87000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14885530', 4, 2.01000000, 2.10000000, 3.97000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14562369', 4, 3.98000000, 2.49000000, 4.13000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14484171', 4, 2.25000000, 3.09000000, 4.20000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14362190', 4, 2.39000000, 2.82000000, 2.04000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13949165', 4, 4.22000000, 2.05000000, 4.08000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13753261', 4, 2.91000000, 3.58000000, 3.54000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13740398', 4, 2.69000000, 4.07000000, 3.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13585677', 4, 2.02000000, 4.02000000, 4.09000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13551644', 4, 3.08000000, 2.82000000, 2.54000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13550256', 4, 2.98000000, 2.23000000, 4.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13500861', 4, 2.52000000, 3.26000000, 4.39000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12938335', 4, 3.97000000, 4.05000000, 2.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12790181', 4, 3.42000000, 4.15000000, 2.92000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12676231', 4, 3.60000000, 2.61000000, 3.27000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12665540', 4, 4.17000000, 4.26000000, 3.34000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12649105', 4, 3.90000000, 3.55000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12515986', 4, 4.00000000, 3.37000000, 3.88000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11972722', 4, 2.16000000, 3.24000000, 2.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11948285', 4, 2.40000000, 2.22000000, 3.49000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11933250', 4, 4.27000000, 3.52000000, 3.05000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11822923', 4, 3.95000000, 4.45000000, 2.49000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11663197', 4, 3.80000000, 2.65000000, 3.66000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11476583', 4, 2.81000000, 2.42000000, 4.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11459913', 4, 2.47000000, 4.35000000, 3.63000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11337407', 4, 3.47000000, 2.42000000, 3.97000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10998709', 4, 4.42000000, 2.47000000, 3.38000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10955111', 4, 2.36000000, 3.46000000, 4.37000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10893477', 4, 3.88000000, 4.49000000, 4.18000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10804413', 4, 4.11000000, 3.78000000, 4.08000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10617672', 4, 3.29000000, 2.83000000, 3.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10615715', 4, 3.19000000, 4.28000000, 3.27000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10525777', 4, 2.56000000, 4.34000000, 3.89000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10433607', 4, 2.68000000, 4.17000000, 2.93000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10366365', 4, 3.00000000, 3.18000000, 3.00000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10284247', 4, 4.40000000, 4.26000000, 3.34000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16971504', 5, 4.19000000, 2.41000000, 3.29000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16945259', 5, 3.81000000, 3.55000000, 3.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16885578', 5, 4.11000000, 2.83000000, 3.27000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16626786', 5, 2.42000000, 4.17000000, 2.74000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('16543708', 5, 2.99000000, 4.14000000, 4.27000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15877030', 5, 2.97000000, 2.44000000, 2.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15788253', 5, 2.63000000, 4.00000000, 4.13000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15700939', 5, 3.64000000, 2.54000000, 2.50000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15589962', 5, 2.76000000, 4.31000000, 4.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15578271', 5, 4.24000000, 4.37000000, 2.34000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('15309170', 5, 3.45000000, 2.44000000, 3.71000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14939257', 5, 4.38000000, 4.08000000, 2.64000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14885530', 5, 4.19000000, 4.02000000, 4.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14562369', 5, 3.25000000, 4.30000000, 3.53000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14484171', 5, 3.64000000, 4.16000000, 4.30000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('14362190', 5, 4.32000000, 3.95000000, 4.33000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13949165', 5, 4.23000000, 4.50000000, 2.76000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13753261', 5, 3.21000000, 2.99000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13740398', 5, 3.04000000, 3.33000000, 2.64000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13585677', 5, 3.91000000, 3.85000000, 2.06000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13551644', 5, 2.01000000, 2.70000000, 2.25000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13550256', 5, 2.91000000, 4.31000000, 3.43000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('13500861', 5, 4.29000000, 2.49000000, 3.16000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12938335', 5, 2.14000000, 3.82000000, 3.01000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12790181', 5, 3.44000000, 4.12000000, 2.91000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12676231', 5, 4.37000000, 2.48000000, 2.18000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12665540', 5, 2.58000000, 2.66000000, 2.74000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12649105', 5, 2.42000000, 3.71000000, 3.45000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('12515986', 5, 2.49000000, 3.77000000, 2.94000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11972722', 5, 4.12000000, 2.12000000, 3.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11948285', 5, 4.32000000, 3.14000000, 3.10000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11933250', 5, 2.46000000, 2.40000000, 4.39000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11822923', 5, 3.92000000, 3.55000000, 2.22000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11663197', 5, 2.05000000, 4.02000000, 2.62000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11476583', 5, 4.02000000, 4.36000000, 3.33000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11459913', 5, 3.05000000, 2.46000000, 3.80000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('11337407', 5, 3.95000000, 2.45000000, 2.87000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10998709', 5, 2.50000000, 4.46000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10955111', 5, 4.32000000, 2.97000000, 4.15000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10893477', 5, 3.01000000, 3.10000000, 3.26000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10804413', 5, 4.06000000, 4.00000000, 3.58000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10617672', 5, 2.13000000, 3.91000000, 3.68000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10615715', 5, 3.54000000, 2.23000000, 3.59000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10525777', 5, 2.69000000, 3.32000000, 4.08000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10433607', 5, 3.04000000, 3.32000000, 3.51000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10366365', 5, 2.43000000, 4.18000000, 4.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10284247', 5, 2.11000000, 3.49000000, 2.94000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('10276637', 5, 4.18000000, 2.91000000, 2.71000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09981340', 5, 2.81000000, 2.80000000, 2.91000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09946130', 5, 2.89000000, 2.15000000, 4.47000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09839224', 5, 2.13000000, 3.48000000, 3.99000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09791710', 5, 2.32000000, 4.26000000, 3.32000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09714111', 5, 4.42000000, 3.68000000, 3.51000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09500575', 5, 4.38000000, 2.98000000, 2.42000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09468667', 5, 3.26000000, 4.26000000, 2.39000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09374395', 5, 4.46000000, 3.36000000, 4.13000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09286476', 5, 4.50000000, 3.88000000, 2.45000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('09243989', 5, 3.52000000, 3.65000000, 3.02000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08980159', 5, 3.60000000, 4.17000000, 3.41000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08831906', 5, 3.13000000, 2.60000000, 2.45000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08775794', 5, 4.33000000, 2.52000000, 4.05000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08673644', 5, 3.62000000, 3.07000000, 2.38000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08648751', 5, 2.27000000, 2.43000000, 4.28000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08506364', 5, 4.18000000, 2.90000000, 3.23000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08405911', 5, 3.41000000, 2.91000000, 3.05000000);
INSERT INTO class.exam_result (student_num, exam_seq, math, program, english) VALUES ('08235560', 5, 4.45000000, 3.16000000, 3.61000000);
major 테이블
major 테이블은 아래와 같습니다.
학과 코드, 학과명, 교수명이 있습니다.
1. 테이블 DDL
create table major
(
major_cd varchar(3) null comment '학과코드',
major_nm varchar(100) null comment '학과명',
professor_nm varchar(100) null comment '학과담당교수'
)
comment '시험성적' charset=utf8;
2. 데이터 insert 쿼리
데이터가 많은 관계로 접어 두겠습니다.
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('100', '컴퓨터공학과', '제라드');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('101', '전산학과', '리오넬');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('102', '제어계측학과', '크리스티아누');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('103', '경영학과', '페페');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('104', '조선해양학과', '클린스만');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('105', '물리학과', '조코비치');
INSERT INTO class.major (major_cd, major_nm, professor_nm) VALUES ('106', '신소재공학과', '굴리트');
select SQL 예문
기본 select 문은 테이블 내 데이터를 직접 출력하여 눈으로 확인할 때 사용을 합니다. SQL의 기본이 된다고 보시면 됩니다. 기본 select문을 잘 이해하셔야 다음 과정이 수월해집니다. select 문의 기본구조를 잘 숙지하셔야 합니다.
그리고, column과 row에 관해서도 알고 있어야 합니다.
column과 row는 아래 그림으로 설명할 수 있습니다.
위 그림처럼 열이 column이고, 행이 row가 됩니다.
select문의 기본 구조는 아래 그림과 같습니다.
select, from, where 이 세 개를 키워드라고 합니다. 물론 키워드는 더 있습니다. 우선 기본 구조에서의 키워드를 알려드립니다.
1. "*"를 이용한 기본 select문
select *
from class.student;
이런 경우 select 절에 "*" 를 넣으면 해당 테이블의 모든 데이터를 출력하라는 명령이 됩니다.
아래와 같이 student 테이블 내 모든 칼럼과 row가 출력됩니다.
만약 row수가 아주 많이 있다면 쓰시는 DB 쿼리툴마다 기본적인 fetch row 설정만큼만 초기에 나오게 됩니다.
참고로 저 같은 경우는 datagrip이라는 툴을 쓰고 있으며, fetch row를 250 row로 제한하였습니다.
2. 원하는 칼럼만 출력
위 "*" 예제와 다르게 원하는 컬럼만 출력을 할 수도 있죠.
select name, gender, mobile
from class.student;
이렇게 select SQL을 실행하면 아래와 같이 나옵니다.
select 절에 name, gender, mobile을 넣었더니 위 그림처럼 기입한 3개의 컬럼만 출력이 됩니다.
row 수에는 변함이 없지만 말이죠.
3. 원하는 row만 출력
원하는 row만 출력하기 위해서는 where라는 키워드 절에 조건을 입력하면 됩니다.
바로 예문을 보겠습니다.
select name, gender, mobile
from class.student
where gender = 'M';
위 select SQL을 해석해보면 class.student 테이블에서 gender 칼럼이 "M" 값을 가진 row의 name, gender, mobile 칼럼을 출력해라 라고 할 수 있습니다.
결과를 볼까요?
2번의 예시와는 다르게 gender 값이 "M"인 row들의 값만 출력이 되었습니다.
where절에 조건을 여러 개 줄 수도 있습니다. 이럴 때는 and라는 키워드를 사용합니다.
select *
from class.student
where gender = 'M'
and entrc_year = 2016;
자, 위 select SQL문을 해석해보겠습니다.
class.student 테이블에서 gender 칼럼 값이 "M" 이며, entrc_year 컬럼값이 2016 인 row들의 모든 칼럼을 출력하라.
이렇게 되겠죠.
결과를 보겠습니다.
여기서 조건을 하나 더 주고 싶다면 and를 연이어서 더 붙이면 됩니다.
그렇게 여러 조건을 줄 수 있겠죠.
4. order by 절을 사용하여 출력한 데이터 정렬 하기
데이터를 출력하면서 정렬이 되면 더 좋겠죠.
바로 예문 들어갑니다.
select *
from class.student
where major_cd = 103
order by entrc_year;
자, 위 select SQL문을 해석을 해볼게요.
class.student 테이블에서 major_cd가 103인 row들의 모든 칼럼을 출력하되, entrc_year 컬럼 값을 기준으로 오름차순 정렬하시오.
이렇게 해석할 수 있겠죠.
이렇게, 결과가 entrc_year 순으로 오름차순 정렬이 되어 출력됩니다.
반대로, 내림차순 정렬을 하려면 어떻게 해야 할까요?
select *
from class.student
where major_cd = 103
order by entrc_year desc;
order by 절 마지막 부분에 desc 명령어를 넣었습니다.
이렇게 하면 내림차순 정렬이 됩니다.
5. group by 절을 이용해서 윈도(통계) 함수 사용하기
select SQL을 이용해서 특정 row들을 하나의 row로 groupping 하여 어떤 통계적인 데이터로 표현할 수 있습니다.
우선, class.exam_result 테이블의 데이터가 어떻게 들어가 있는지를 확인해 보겠습니다.
class.exam_result 테이블의 데이터는 위와 같이 있습니다. 학번이 있고, 두 번째 있는 exam_seq는 시험 회차입니다. 그리고 수학, 프로그래밍, 영어 과목의 성적 점수가 들어가 있습니다.
그럼 여기서 회차별로 몇 건의 데이터가 있는지 확인해 보도록 하겠습니다.
select exam_seq, count(*)
from class.exam_result
group by exam_seq;
위 select SQL 예문을 해석하겠습니다.
class.exam_result 테이블의 데이터중 exam_seq별로 그룹핑하여 각 exam_seq별 건수를 출력하라.
이렇게 해석이 되는데요. 결과를 보시겠습니다.
위 결과를 보면 class.exam_result 테이블에는 exam_seq값이 총 1~5까지 있습니다.
각 회차별 데이터의 건수가 1회 차는 66건, 2회 차는 55건....... 5회 차 66건이 있다는 것을 알 수 있습니다.
이번엔 회차별 수학 성적의 평균값을 구해 보는 select SQL을 실행해 보겠습니다.
select exam_seq, avg(math)
from class.exam_result
group by exam_seq;
위 select SQL의 해석도 해보겠습니다.
class.exam_result 테이블의 데이터중 exam_seq별로 그룹핑하여 각 exam_seq별 math(수학 성적)의 평균을 출력하라.
결과를 보겠습니다.
결과를 보면 회차별로 수학 성적의 평균값이 구해진 것을 확인할 수 있습니다.
간단하죠?
지금까지 간단하게 select SQL을 작성하고, 이해하는 시간을 가져봤습니다.
감사합니다.
by.sTricky