我这里有个问题..
假设我有这张桌子......
waktu | tglTransaksiJual | nominal | ongkir | STATUS | idUser
---------------------------------------------------------------------------------------
2013-02-01 00:00:00 | 2013-01-29 15:00:00 | 10000 | 10000 | APPROVED | 1
0000-00-00 00:00:00 | 2013-02-02 15:00:00 | 20000 | 0 | DONE | 2
0000-00-00 00:00:00 | 2013-02-02 15:00:00 | 10000 | 5000 | DONE | 2
2013-02-03 00:00:00 | 2013-02-01 15:00:00 | 20000 | 0 | APPROVED | 3
并且我使用这个查询
SELECT DISTINCT(date(IF(waktu = '0000-00-00 00:00:00', tglTransaksiJual, waktu))) AS thedate, SUM( nominal+ongkir ) AS total
FROM transaksijual
WHERE IF(waktu = '0000-00-00 00:00:00', tglTransaksiJual, waktu) BETWEEN '2013-02-01' AND '2013-02-05' AND status LIKE 'DONE%' AND idUser LIKE '2%'
GROUP BY thedate
ORDER BY thedate ASC
但我得到的结果是
thedate | total
-------------------
2013-02-01 | 30000
我想要的是这样的
thedate | total
------------------
2013-02-01 | 0
2013-02-02 | 35000
2013-02-03 | 0
我怎样才能做到这一点??那可能吗??所以结论是..当没有数据时,我想获取 0 值并获取行...