The original SQL statement would be:
select t3.id as groupId, t3.name as groupName, count(*) as total,
sum(case when t1.state = '2' then 1 else 0) as pending,
sum(case when t1.state = '2' then 1 else 0) as processing,
sum(case when t1.state in ('4'.'5'.'0') then 1 else 0) as solved
from question t1,customer t2,cmbgroup t3
where t1.source_id = t2.id
whereT2. group_id = t3.id and 1575354492381 < T1. sta_DTM and t1. sta_DTM > 1576218492381 group by groupIdCopy the code
SQL is used to query and count all groups of tasks within a department within a period of time, but it does not return data. I replace the passed timestamp with mysql’s built-in function now() to query data, and only use the first timestamp field filter, no problem. The data cannot be found if the following filter is applied (the timestamp below is now())
Finally I changed the SQL statement to the following:
select t3.id as groupId, t3.name as groupName, count(*) as total,
sum(case when t1.state = '2' then 1 else 0) as pending,
sum(case when t1.state = '2' then 1 else 0) as processing,
sum(case when t1.state in ('4'.'5'.'0') then 1 else 0) as solved
from question t1,customer t2,cmbgroup t3
where t1.source_id = t2.id
whereT2. group_id = t3.id and 1575354492381 < T1. sta_DTM and unix_timestamp(t1.sta_DTM) > 1576218492381(timestamp) group by groupIdCopy the code