我這裏有一個問題..MySQL的組返回所有的行
可以說我有這個表...
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
而且我想要的是l ike this
thedate | total
------------------
2013-02-01 | 0
2013-02-02 | 35000
2013-02-03 | 0
我該怎麼做?那可能嗎?? 所以得出的結論是..當沒有數據我想要得到0值,並獲得該行...
你'WHERE'條件指定'DONE'和'ID用戶= 2',但這些不匹配任何其他日期列。這是故意的還是什麼? – 2013-02-14 04:37:20
是的......我的問題如何返回帶0values行時沒有條件匹配 – user2070749 2013-02-14 04:49:05