Subject Re: [firebird-support] average in group by month
Author Alex Taylor
Hi James!

Maybe I understood what You want. Here is a query that will produce a
monthly total by customer without any input parameters. If You want the
average of course You have to change the aggregate function to AVG.
Here is the code:

SELECT INV.CUST_ID, CUST.NAME,
EXTRACT (MONTH FROM DATE_OF_PAYMENT), SUM(TOTAL_AMOUNT)
FROM INVOICE INV, CUSTOMERS CUST WHERE INV.CUST_ID=CUST.CUST_ID
GROUP BY INV.CUST_ID, CUST.NAME,
EXTRACT (MONTH FROM DATE_OF_PAYMENT)

Regards:Alex