1 create table chengji ( 2 name varchar(10), 3 kecheng varchar(10), 4 fenshu int 5 ); 6 insert into chengji values(‘张三‘, ‘语文‘, 81); 7 insert into chengji values(‘张三‘, ‘数学‘, 75); 8 insert into chengji values(‘李四‘, ‘语文‘, 76); 9 insert into chengji values(‘李四‘, ‘数学‘, 90); 10 insert into chengji values(‘王五‘, ‘语文‘, 81); 11 insert into chengji values(‘王五‘, ‘数学‘, 100); 12 insert into chengji values(‘王五‘, ‘英语‘, 90); 13 14 15 -- 用一条SQL语句查询出每门课都大于80分的学生姓名 16 select distinct name 17 from chengji 18 where name not in ( 19 select distinct name 20 from chengji 21 where fenshu <= 80);
原文:http://www.cnblogs.com/wanghui390/p/4041719.html