Php 用于每日汇总数据的SQL查询
我使用以下SQL查询从MySQL数据库获取数据Php 用于每日汇总数据的SQL查询,php,mysql,sql,Php,Mysql,Sql,我使用以下SQL查询从MySQL数据库获取数据 select classid,start, count(case when classid='Handball' then 1 end) as handball_count from signature where classid='Handball' group by start 例如,日期为2016.12.01。10:51:58格式 它应该每天进行,例如2016.12.01。10:51:58和2016.12.01。15:51:
select
classid,start,
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start
例如,日期为2016.12.01。10:51:58格式
它应该每天进行,例如
2016.12.01。10:51:58
和2016.12.01。15:51:58
在此查询中不应是其他条目。我应该怎样分组?我想对每天每项活动的参与者进行总结,不以参与者签名的日期分隔。请将日期时间
转换为日期
SELECT CONVERT(date, date)
or
GROUP BY CAST(date AS DATE)
select
classid,CONVERT(date, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by date,classid
请将
datetime
转换为date
SELECT CONVERT(date, date)
or
GROUP BY CAST(date AS DATE)
select
classid,CONVERT(date, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by date,classid
你可以试试这个
SELECT count(case when classid='Handball' then 1 end) as handball_count,
classid,DATE(start) DateOnly
FROM signature where classid='Handball'
GROUP BY DateOnly;
你可以试试这个
SELECT count(case when classid='Handball' then 1 end) as handball_count,
classid,DATE(start) DateOnly
FROM signature where classid='Handball'
GROUP BY DateOnly;
我正在考虑将
start
作为您的日期字段,因此这可能会对您有所帮助
select
classid,CONVERT(start, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start
另外,您的日期格式与标准timestam不匹配,请查看。可能下面的参考资料也可以帮助你
select
classid,CONVERT(start, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start
我正在考虑将
开始
作为您的日期字段,因此这可能会对您有所帮助
select
classid,CONVERT(start, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start
另外,您的日期格式与标准timestam不匹配,请查看。可能下面的参考资料也可以帮助你
select
classid,CONVERT(start, date),
count(case when classid='Handball' then 1 end) as handball_count
from signature where classid='Handball'
group by start
您可以将日期时间强制转换为日期。您使用的是MySQL还是SQL Server?而且,这些时间戳似乎没有任何标准格式。它们是什么类型的?您可以将日期时间强制转换为日期。您使用的是MySQL还是SQL Server?而且,这些时间戳似乎没有任何标准格式。它们是什么类型的?