我有以下查询:
SELECT a.status, count(a.status) FROM
(SELECT 'Delivered' AS status
UNION ALL SELECT 'Buffered'
UNION ALL SELECT 'Not Delivered'
UNION ALL SELECT 'Not Reported') a
LEFT JOIN
bulk_sms_numbers
ON a.status = bulk_sms_numbers.delivery_status
WHERE bulk_sms_id = 52
GROUP BY a.status;
和以下结果:
+-----------+-----------------+
| status | count(a.status) |
+-----------+-----------------+
| Buffered | 10 |
| Delivered | 3200 |
+-----------+-----------------+
我希望结果集包含联合所有查询中列出的所有可能状态
我需要的示例输出。
+---------------+-----------------+
| status | count(a.status) |
+---------------+-----------------+
| Buffered | 10 |
| Delivered | 3200 |
| Not Delieverd | 0 |
| Not Reported | 0 |
+---------------+-----------------+
我正在使用 MySql