dsilhx5830 2016-12-02 05:14
浏览 117
已采纳

SQL查询每天汇总数据

I use following SQL query to get data from MySQL database.

select
    classid,start,
    count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start

Date is for example 2016.12.01. 10:51:58 format.

It should be on a daily basis, so for example 2016.12.01. 10:51:58 and 2016.12.01. 15:51:58 shouldn't be a different entry in this query. How should I group by day? I would like to summarize participants for each activity per day and not separated by the date of the participant's signature.

  • 写回答

3条回答 默认 最新

  • dscbxou1900343 2016-12-02 05:18
    关注

    you can try this

    SELECT count(case when classid='Handball' then 1 end) as handball_count,
       classid,DATE(start) DateOnly 
    FROM signature where classid='Handball'
    GROUP BY DateOnly;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)