只需将子查询与所需日期和使用日期放在一起
left outer join:
select d.thedate, coalesce(SUM(amount), 0) AS amountfrom (select date('2014-04-25') as thedate union all select date('2014-04-24') union all select date('2014-04-23') union all select date('2014-04-22') union all select date('2014-04-21') union all select date('2014-04-20') union all select date('2014-04-19') ) d left outer join transactions t on t.purchase_date = d.thedate and vendor_id = 0GROUP BY d.thedateORDER BY d.thedate DESC;


