我有一个查询应该从一个表中提取所有预订,然后Quantity
从链接表中对列求和。我在查询中设置了正确的连接,但由于某种原因,它只显示至少有一个数量记录的预订。下面的查询应返回 4 行,其中 3 行总和为零,但仅返回单行。有任何想法吗?
SELECT
tblReservations.Subaccount,
SUM(tblBilling_Detail.Quantity)
FROM tblBilling_Detail
RIGHT JOIN tblReservations
ON tblBilling_Detail.Linked_Account = tblReservations.Subaccount
WHERE Usage_Start
BETWEEN tblReservations.Reservation_Start
AND tblReservations.Reservation_End
GROUP BY tblReservations.Subaccount