SQL多条件统计查询

本文介绍了如何使用SQL进行多条件统计查询,包括利用WHERE子句设置复杂条件,结合GROUP BY和HAVING子句进行数据分组过滤,以及运用聚合函数如COUNT(), SUM()等进行统计分析。通过实例解析,帮助读者掌握高级SQL查询技巧。" 130682692,11130912,SpringBoot源码分析:SpringApplication的启动流程,"['java', 'Springboot', '源码分析']
摘要由CSDN通过智能技术生成
SELECT  date_format(from_unixtime(created_at),'%Y%m%d')as 'time' ,count(1) as 'num',
(select count(1) from tre_upgrade_log where new_grade=1 and date_format(from_unixtime(created_at),'%Y%m%d')=date_format(from_unixtime(t.created_at),'%Y%m%d'))as 'grade_01',
(select count(1) from tre_upgrade_log where new_grade=2 and date_format(from_unixtime(created_at),'%Y%m%d')=date_format(from_unixtime(t.created_at),'%Y%m%d'))as 'grade_02',
(select count(1) from tre_upgrade_log where new_grade=3 and date_format(from_unixtime(created_at),'%Y%m%d')=date_format(from_unixtime(t.created_at),'%Y%m%d'))as 'grade_03',
(select count(1) from tre_upgrade_log where new_grade=4 and date_format(from_unixtime(created_at),'%Y%m%d')=date_format(from_unixtime(t.created_at),'%Y%m%d'))as 'grade_04',
(select count(1) from tre_upgrade_log where new_
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值