python if else用法筛选出成绩不及格的学生的姓名_【IT专家】sql语句,如何查询一个班的学生成绩都及格的学生的姓名...

本文由我司收集整编,推荐下载,如有疑问,请与我司联系

sql

语句

,

如何查询一个班的学生成绩都及格的学生的姓名

2011/03/09

10

where

成绩

60and........

关键是如何判断一个班的都及格

了??????????????????

select

班级,学生姓名

from

成绩表

where

成绩

60and

班级

notin(selectdistinct

班级

from

成绩表

where

成绩

60)

select*from

成绩表

twherenotexists(select1from

成绩表

wheret.

班级

=

班级

andt.

成绩

60)

select

班级

,sum(casewhen

成绩

=60then1else0end)

及格人数

,count(*)

总人数

from

成绩表

groupby

班级

withcteas(select

班级

,sum(casewhen

成绩

=60then1else0end)

及格

人数

,count(*)

总人数

from

成绩表

groupby

班级

)select

班级

,(casewhen

及格人数

总人

then’

不完全及格

’else’

全部及格

’end)

及格标识

fromcte

if(selectcount(0)from

成绩

)=(selectcount(0)from

成绩表

where

成绩

=60)print’

都及格了

’elseprint’

有人不及格

SQL

语句练习题参考答案

1

selectSname,Ssex,ClassfromStudent;2

selectdistinctdepartfromteacher;3

selectSnoas’

学号

’,Snameas’

姓名

’,Ssexas’

’,Sbirthdayas’

出生日期

’,Classas’

班号

’fromstudent;

selectSnoas

学号

,Snameas

,Ssexas

性别

,Sbirthdayas

出生日期

,Classas

班号

fromstudent;4

select*fromscorewheredegreebetween60and80;

select*fromscorewheredegree

=60anddegree

5

select*fromscorewheredegreein(85,86,88);6

select*fromstudentwhere

orSsex=‘

’;7

select*fromstudentorderbyclassdesc;8

select*fromscoreorderbycnoasc,degreedesc;

select*fromscoreorderbycno,degreedesc;9

selectcount(*)asCNTfromstudentwhere

;10

selectSnoas’

学号

’,cnoas’

课程号

’,degreeas’

最高

’fromscorewheredegree=(selectmax(degree)fromscore)11

selectavg(degree)as

课程平

均分

fromscorewherecno=‘3-105’;12

selectcno,avg(degree)fromscorewherecnolike’3%’groupbycnohavingcount(*)

13

selectSnofromscoregroupbySnohavingmin(degree)

70andmax(degree)

14

selectstudent.Sname,score.Cno,score.degreefromstudent,scorewherestudent.Sno=score.Sno

;15

selectx.Sno,y.Cname,x.degreefromscorex,courseywherex.Cno=y.Cno;16

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值