浅浅星空 2022-11-20 15:42 采纳率: 66.7%
浏览 2

mysqlcountif记录为空

为什么这样写活动一的输出结果中会有uid=none而没有1005的记录呀~~已经限制了非空了呀,又是想了一下午啥没想出来的一天。

img

select * from(
select if(count(if(score>=85,1,null))=count(uid),uid,null) as uid,'activity1' as activity
from
(select uid,score,submit_time,start_time,release_time from exam_record 
join examination_info using(exam_id)
where tag='SQL'
)a
where uid is not null
group by uid
)t1
union
select * from(
select if(count(if(timestampdiff(second,start_time,submit_time)<=duration*30 and score>80 and year(start_time)=2021 and difficulty='hard',1,null))>=1,uid,null) as uid,'activity2' as activity
from
(select uid,score,submit_time,start_time,release_time,duration,difficulty from exam_record 
join examination_info using(exam_id)
where tag='SQL'
)a
where uid is not null
group by uid
) t2
where uid is not null
order by uid

  • 写回答

1条回答 默认 最新

  • 鱼找水需要时间 Java领域优质创作者 2022-11-20 20:16
    关注

    在数据库执行看看 uid为空的那条数据,是null还是空字符串呢

    评论

报告相同问题?

问题事件

  • 创建了问题 11月20日

悬赏问题

  • ¥15 有偿求苍穹外卖环境配置
  • ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
  • ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
  • ¥15 clousx6整点报时指令怎么写
  • ¥30 远程帮我安装软件及库文件
  • ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
  • ¥20 深信服vpn-2050这台设备如何配置才能成功联网?
  • ¥15 Arduino的wifi连接,如何关闭低功耗模式?
  • ¥15 Android studio 无法定位adb是什么问题?
  • ¥15 C#连接不上服务器,