我有什么特别的原因让 MySQL 在允许使用的date_sent_at
同时WHERE
不允许使用 inGROUP BY
吗?
SELECT
CONCAT(type, '_', IF(om.is_auto, 'auto', 'user')) AS subtype,
DATE(om.sent_at) AS date_sent_at,
COUNT(om.id) AS sends
FROM outgoing_message om INNER JOIN outgoing_message_customers AS omc
ON om.id = omc.outgoing_message_id
WHERE
omc.customer_id = 2
AND
om.status <> 'pending'
AND
date_sent_at >= '2012-01-01'
GROUP BY subtype, date_sent_at
编辑:我知道(当然)我可以用DATE(om.sent_at) >= '2012-01-01'
.