So, I need some code help. I've got an awkward little MySQL table that just keeps growing and growing.
Let's assume that a set of clients, some in certain countries, that I need to 'total' the invoices for (need to calculate GST)
So, two tables contain the data I need -- one table has their ID and their country (In this case, Canada!). In our second table I've got their invoices, of which one variable is their ID from table1, and the another variable I've got to retrieve (and sum). Note it would help if they were summed into quarters. Invoices also have a duedate in the following syntax: 2006-06-26 (year-month-day).
In table 1 the ID set for each client is named: id -- it's numeric, e.g. 1-200000 In table 1 the country is: CA
In table 2 the variable for duedates is: duedate The other variable we require is the subtotal
Out of table2 I need to basically only grab whichever clients are in country CA (data from table1) and SUM their invoices.
The output should be as follows: 1st quarter sum: $x,xxx 2nd quarter sum: $x,xxx How?