查看: 2166|回复: 0
打印 上一主题 下一主题
收起左侧

[数据库部分] 188、用一条SQL语句查询出每门课都大于80分的学生姓名 

[复制链接]

566

主题

713

帖子

3827

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3827
楼主
跳转到指定楼层
发表于 2016-9-8 18:12:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
188、用一条SQL语句查询出每门课都大于80分的学生姓名 

name   kecheng   fenshu
张三     语文       81
张三     数学       75
李四     语文       76
李四     数学       90
王五     语文       81
王五     数学       100
王五     英语       90

准备数据的sql代码:

create table score(id int primary key auto_increment,name varchar(20),subject varchar(20),score int);

insert into score values

(null,'张三','语文',81),

(null,'张三','数学',75),

(null,'李四','语文',76),

(null,'李四','数学',90),

(null,'王五','语文',81),

(null,'王五','数学',100),

(null,'王五 ','英语',90);

 

提示:当百思不得其解时,请理想思维,把小变成大做,把大变成小做,

 

答案:
A: select distinct name from score  where  name not in (select distinct name from score where score<=80)

 

B:select distince name t1 from score where 80< all (select score from score where name=t1);


来自安卓客户端来自安卓客户端
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 打开微信扫一扫