So I'm sitting here in a pinch and my brain just refuses to work...

2 tables, a customer and an invoice table. What is the proper SQL to get all customers records, plus the sum of a column in the invoice table with a relation on the customer ID, but not all customers might have an invoice record..

Something like

SELECT *,sum(im.total) as total FROM customers AS c, invoice_master as i WHERE i.customer_id = c.customer_id GROUP BY c.customer_id;

Except that, of course, means that every customer has to have a record in the invoice table or they won't show in the list. I just want 0 to show for total for those customers that don't have a record in the invoice table.

Much appreciation up front as I know this is probably one of those "duh" kinds of questions..

-- Mitchell

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to