mysql相关

mysql
1.union

select name  from tb1 where score=(
SELECT max(score) from tb1 

)
union 
select name  from  tb1 where score=(
SELECT min(score) from tb1 

)

2.两门分数加起来的第2-5名,group by

select name, count(score),sum(score)  from tb1 
 group by name 
HAVING count(score)=2 
ORDER BY
sum(score) desc 
limit 1,4;

3.两门加起来低于 150,having分组过滤条件

select name ,sum(score) from tb1  group by name 
having count(score)=2 
and   sum(score)<150

4.两门平均分在60-80,having分组过滤条件+avg()平均

select name ,avg(score) from tb1  group by name 
having count(score)=2 
and  avg(score)>=60 and  avg(score)<=80;

5.总分大于150,平均分小于90的人数
#总分大于150,平均分小于90的人数

select count(*)as '符合人数'
from
(select id from  tb1
group by name
HAVING sum(score)>100 and avg(score)<90

) a

6.看不懂,语文不好…

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值