统计一周内工作日志数量并且算出那个时间段谁没写
select user_id,name,((select count(1) from sys_user_1 A where A.user_id = B.user_id)) from sys_user b where (select count(1) from sys_user_1 A where A.user_id = B.user_id) = 0
一月统计
SELECT
COUNT( id ),date( create_time )
FROM
tt_vs_recycle_order
WHERE
DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( create_time )
GROUP BY
DATE_FORMAT( create_time, "%Y-%m-%d" ) ORDER BY DATE_FORMAT( create_time, "%Y-%m-%d" )
select a.click_date,IFNULL(b.count,0),b.yhbh
from (
SELECT curdate() as click_date
union all
SELECT date_sub(curdate(), interval 1 day) as click_date
union all
SELECT date_sub(curdate(), interval 2 day) as click_date
union all
SELECT date_sub(curdate(), interval 3 day) as click_date
union all
SELECT date_sub(curdate(), interval 4 day) as click_date
union all
SELECT date_sub(curdate(), interval 5 day) as click_date
union all
SELECT date_sub(curdate(), interval 6 day) as click_date
) a left join (
select date(start_date) as datetime, count(*) as count,GROUP_CONCAT(yhbh) as yhbh
from work_log
group by date(start_date)
) b on a.click_date = b.datetime;
select count(DISTINCT yhbh),date(start_date) as date,GROUP_CONCAT(DISTINCT yhbh) from work_log where datediff(now(),start_date)<=7
group by day(start_date);