如果聚集函数作用域空值列,遇到空值行将被忽略。
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (103,'3-245',86);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (105,'3-245',75);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (109,'3-245',68);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (103,'3-105',92);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (105,'3-105',88);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (109,'3-105',76);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (101,'3-105',64);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (107,'3-105',91);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (108,'3-105',78);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (101,'6-166',85);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (107,'6-106',79);
INSERT INTO SCORE1(SNO,CNO,DEGREE)VALUES (108,'6-166',81);
insert into score1 (SNO,CNO,DEGREE) values(109, '6-106', null);
select avg(degree) from score1;
80.25
select avg(degree) from score1 where degree is not null;
80.25
select count(degree) from score1
12
select count(*) from score1;
13
select max(degree), min(degree) from score1;
92 64