0
目前,我實現了與此查詢一個表來做到這一點:如何從兩個表中總結列,如果一個月的比賽和小組按月
SELECT EXTRACT(MONTH FROM date) as month, SUM(total) as total FROM invoices GROUP BY month ORDER BY month ASC
但現在我要瘋了試圖返回來自兩列的結果相同,比如說total1和total2,並且按月分組,如果一個月內沒有發票,結果應該是cero。
表結構和預期的結果:
invoices payments
date date
total income
month totalInvoices totalPayments
1 10005 8017
2 756335 5019
3 541005 8017
4 34243 8870
如何實現這一目標?有什麼建議麼?
表結構和預期輸出請。 –
我修正了這個問題,@YusufHassan – Nelson