而不是返回5行,我如何编辑以下查询以返回

date --- rows found
date --- rows found
date --- rows found


这是查询

SElECT * FROM emails WHERE maildate >= DATE_ADD(CURDATE(), INTERVAL -3 DAY) and company_id = 1 order by maildate desc

最佳答案

maildateCOUNT(*)上的组应该起作用:

SELECT maildate, COUNT(*) as TotalEmails --change alias as desired
FROM emails
WHERE maildate >= DATE_ADD(CURDATE(), INTERVAL -3 DAY)
AND company_id = 1
GROUP BY date(maildate) --Remove timestamp for grouping
ORDER BY maildate desc


虽然尚不清楚您要返回什么。样本数据和预期的输出将有所帮助。

10-02 23:43