我有一张表:apns_devices
有列:estado, modified, pid, etc.
我想根据上次修改时间(即上周、上个月、昨天、今天和总数)获得一些统计信息。现在我正在为每个时期做一个查询(嵌套),例如:
SELECT t1.estado, t1.siempre, t2.hoy
FROM
(SELECT *, COUNT(pid) as siempre FROM `apns_devices` GROUP BY estado) as t1
INNER JOIN
(SELECT *, COUNT(pid) as hoy FROM `apns_devices` WHERE DATE (modified) = CURRENT_DATE GROUP BY estado) as t2
ON t1.estado = t2.estado
这是今天的总和
为了加快脚本速度;¿ 我怎样才能在一个查询中做到这一点?