select count(1) as number from(SELECT id FROM production
select count(1) as number from(SELECT id FROM production
where spot_id ='{spot_id}' and total >0 and return_time is not null and time_to_sec(timediff(return_time, created_at))<3600) as rs
where spot_id ='{spot_id}' and total >0 and return_time is not null and (UNIX_TIMESTAMP(return_time) - UNIX_TIMESTAMP(created_at))<3600) as rs
union all
union all
select count(1) as number from(SELECT id FROM production
select count(1) as number from(SELECT id FROM production
where spot_id ='{spot_id}' and total >0 and return_time is not null and time_to_sec(timediff(return_time, created_at))>3600 and time_to_sec(timediff(return_time, created_at))<=7200) as rs
where spot_id ='{spot_id}' and total >0 and return_time is not null and (UNIX_TIMESTAMP(return_time) - UNIX_TIMESTAMP(created_at))>3600 and (UNIX_TIMESTAMP(return_time) - UNIX_TIMESTAMP(created_at))<=7200) as rs
union all
union all
select count(1) as number from(SELECT id FROM production
select count(1) as number from(SELECT id FROM production
where spot_id ='{spot_id}' and total >0 and return_time is not null and time_to_sec(timediff(return_time, created_at))<7200) as rs;
where spot_id ='{spot_id}' and total >0 and return_time is not null and (UNIX_TIMESTAMP(return_time) - UNIX_TIMESTAMP(created_at))<7200) as rs;