Subject | Re: [firebird-support] average in group by month |
---|---|
Author | Alex Taylor |
Post date | 2004-02-26T16:53:09Z |
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
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