select
the_date as day,
sec_to_time(avg(timestampdiff(second, start_time, end_time))) as duration
from ...
group by the_date;
你希望1-7天,8-14天,15-21天,22天每月结束。使用 CASE WHEN 建立团队。
select
year(the_date) as year,
month(the_date) as month,
case
when day(the_date) <= 7 then '01-07'
when day(the_date) <= 14 then '08-14'
when day(the_date) <= 21 then '15-21'
else '22-end'
end as day_range,
sec_to_time(avg(timestampdiff(second, start_time, end_time))) as duration
from ...
group by year, month, day_range
order by year, month, day_range;
1条答案
按热度按时间vaqhlq811#
您有一个每天分组的查询,例如:
你希望1-7天,8-14天,15-21天,22天每月结束。使用
CASE WHEN
建立团队。