I have 2 tables, t1 (col CustomerName, InvoiceNo) and t2 (col InvoiceNo, Model, SN)
Data is like:
CustomerName InvoiceNo InvoiceNo Model SN
Name1 Inv1 Inv1 A A-1
Name1 Inv2 Inv1 B B-1
Name1 Inv3 Inv1 A A-2
Name2 Inv4 Inv2 B B-2
Name2 Inv5 Inv2 C C-1
I want to get a total (count(SN)) for InvoiceNo and also total for CustomerName.
SELECT t1.CustomerName, t1.InvoiceNo, COUNT(t2.SN) as Qty FROM t1 INNER JOIN t2 on t1.InvoiceNo=t2.InvoiceNo
GROUP BY t1.CustomerName, t1.InvoiceNo
This only shows the total for InvoiceNo. How can I get total for CustomerName and InvoiceNo in one query? Or possible?
Thank you very much in advance. HB