Hi Gurus,
I have a table containing data like followings:
cust_id amount startDate endDate
123 2345.00 12/01/2004 11/30/2005
123 2440.00 12/01/2005 11/30/2006
124 3660.00 05/01/2005 04/30/2006
125 234.00 11/01/2005 10/31/2006
126 654.00 02/01/2006 08/31/2006
The fiscal year starts on October 1 for each year. How can I construct a query to calculate the annual amount and the first quarter amount for 2006? The annual/quarter amount should be calcalted as follows: 1.) find the total months between "startDate" and "endDate"; 2.) get the average amount for each month by dividing "amount" by the total months (as in Step 1); 3.) add any amount if a month between 10/01/2005 and 12/31/2005. For instance, the customer whose Id is 123 has two months falling in the first quarter of 2006. Hence, I need to add [(amount/12) * 2] into the total. The customer with ID of 126 should not be counted in the first quarter amount, but should be in the annual amount.
Any idea on the annual amount and the quarterly amount? Appreciate so much for any of your help on this.
Fox12
I have a table containing data like followings:
cust_id amount startDate endDate
123 2345.00 12/01/2004 11/30/2005
123 2440.00 12/01/2005 11/30/2006
124 3660.00 05/01/2005 04/30/2006
125 234.00 11/01/2005 10/31/2006
126 654.00 02/01/2006 08/31/2006
The fiscal year starts on October 1 for each year. How can I construct a query to calculate the annual amount and the first quarter amount for 2006? The annual/quarter amount should be calcalted as follows: 1.) find the total months between "startDate" and "endDate"; 2.) get the average amount for each month by dividing "amount" by the total months (as in Step 1); 3.) add any amount if a month between 10/01/2005 and 12/31/2005. For instance, the customer whose Id is 123 has two months falling in the first quarter of 2006. Hence, I need to add [(amount/12) * 2] into the total. The customer with ID of 126 should not be counted in the first quarter amount, but should be in the annual amount.
Any idea on the annual amount and the quarterly amount? Appreciate so much for any of your help on this.
Fox12