标签:分组
1.查询出每门课都大于 80 分的学生姓名create table test2( id int not null auto_increment, name varchar(10), kecheng varchar(10), fenshu int, primary key(id) ) insert into test2(name,kecheng,fenshu) values('张三','语文',81 ); insert into test2(name,kecheng,fenshu) values('张三','数学',75 ); insert into test2(name,kecheng,fenshu) values('李四','语文',76 ); insert into test2(name,kecheng,fenshu) values('李四','数学',90 ); insert into test2(name,kecheng,fenshu) values('王五','语文',81 ); insert into test2(name,kecheng,fenshu) values('王五','数学',100); insert into test2(name,kecheng,fenshu) values('王五','英语',90 ); -- (1) select name from test2 group by name having min(fenshu) > 80; 王五 -- (2) select distinct name from test2 where name not in (select distinct name from test2 where fenshu<=80) 王五
标签:分组
原文地址:http://blog.51cto.com/13634837/2118628