Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Complex MAth Result Set

Author  Topic 

Scott
Posting Yak Master

145 Posts

Posted - 2000-11-18 : 08:05:23
I have a table with ID, START, END & AMOUNT.
I need to run a query, trigger or sp that will return each month with the % of the ammount allocated to that month depending on the start and end dates.

eg: Project1, 15 Jan 2000, 13 March 2000, $20 000.00
Project2, 5 Feb 2000, 4 April 2000, 13 500.00

Project1 duration in days = 59
Cost per day = $20 000/59 = $338.98
cost per month: Jan 17*338.98=$5762.66, Feb=$9830.42, Mar=$4406.74

Therefore result set would be:

Jan 2000 $5762.66
Feb 2000 $15455.42
March 2000 $11381.74
April 2000 $900.00

ie: All costs per month for all projects added together.


   

- Advertisement -