我有一个查询,我试图按日期和类别获取托盘数量
SELECT b.Date,b.Decision, COUNT(b.Decision) AS Trays
FROM bags b
INNER JOIN MatrixTable tb
ON tb.MachineID= b.MachineID
WHERE tb.AirPortCode = 'ATL'
AND b.Decision= 'a'
AND b.Date BETWEEN '2023-01-01' AND '2023-01-31'
GROUP BY b.Date,b.Decision
输出给出了每个
Date
和 Decision
的结果,但不包括计数为 0 的日期,以及计数为 0 的事实。
2023-01-04 a 63
2023-01-05 a 245
2023-01-06 a 147
2023-01-07 a 183
2023-01-08 a 223
2023-01-09 a 65
2023-01-10 a 141
2023-01-11 a 48
2023-01-12 a 207
2023-01-13 a 77
2023-01-14 a 133
2023-01-15 a 196
2023-01-17 a 132
2023-01-18 a 131
2023-01-19 a 148
2023-01-20 a 132
2023-01-21 a 171
2023-01-22 a 206
2023-01-23 a 174
2023-01-25 a 156
2023-01-26 a 197
2023-01-27 a 205
2023-01-28 a 180
2023-01-29 a 295
2023-01-30 a 145
2023-01-31 a 168
输出中应该有以下记录
2023-01-01 a 0
2023-01-02 a 0
2023-01-03 a 0
2023-01-16 a 0
2023-01-24 a 0
我再次运行查询,这次是
LEFT OUTER JOIN
但得到了相同的结果。
如何获取输出中的所有日期,包括具有 0 个匹配记录的日期?