最近使用SQL遇到問題
先看第一段語法:
SELECT invoice_details_new.invoice_number,invoicing_system_new.invoice_date,invoice_details_new.quantity,invoice_details_new.price,invoice_details_new.money FROM Invoicing_system_new LEFT JOIN invoice_details_new ON invoicing_system_new.invoice_number = invoice_details_new.invoice_number WHERE invoice_date LIKE '2021-01%' ORDER BY invoicing_system_new.invoice_number
這是第一段語法執行結果:
再看第二段語法:
SELECT DISTINCT invoice_details_new.invoice_number,invoicing_system_new.total_amount,invoicing_system_new.allowance,invoicing_system_new.total FROM Invoicing_system_new LEFT JOIN invoice_details_new ON invoicing_system_new.invoice_number = invoice_details_new.invoice_number WHERE invoice_date LIKE '2021-01%' ORDER BY invoicing_system_new.invoice_number
這是第二段語法執行結果:
目前研究很久只能做出這樣:
下圖是希望做到的結果:
這問題困擾很久,感覺跟LEFT JOIN有關
一直試但是都沒有結果,求SQL大神寫個範例指導