Wednesday, October 29, 2008

Query to get earnings

Stupid software. Here’s a nice query to get earnings by year by customer. The billing history table is historysummary.

SELECT customers.customername, SUM(historysummary.total), year(historysummary.invoicedate) from customers INNER JOIN historysummary ON historysummary.customer = customers.customer GROUP BY customers.customername, year(historysummary.invoicedate) ORDER BY year(historysummary.invoicedate), customers.customername

No comments: