我有两张桌子 - 报价和预订
我选择“报价日期”来显示星期几,但如果在没有报价的日子预订,则没有“报价日期”,因此该行永远不会显示。
如何创建过去30,60或90天内每天的列,然后显示该指定日期的报价数量和预订数量?
当前SQL使用QuoteDate:
SELECT
cast(q.created as date) AS QuoteDate,
count(q.id) AS Quotes,
count(b.quote_id) AS Bookings
FROM quotes q
LEFT OUTER JOIN bookings b ON b.quote_id=q.id
WHERE year(q.created)='2010'
AND month(q.created)='09'
GROUP BY cast(q.created as date)
ORDER BY cast(q.created as date) DESC
这些结果不会在没有引号的日子显示预订......