我有一张包含资源信息的表格,基本信息是:
ID Total Start End Used
----------------------------------------------
1 350 01-01-2012 31-12-2012 80.6%
2 250 01-01-2012 31-12-2012 51.5%
3 3500 01-01-2012 31-07-2013 12.5%
4 350 01-01-2012 31-10-2012 91.0%
列是:
Total
-- 资源总数(货币、时间、纸张等)。Start
-- 资源开始日期End
-- 资源结束日期Used
-- 迄今为止使用的资源百分比
我必须尝试计算(或估计)资源何时会以目前使用的速度耗尽。
我尝试了几种不同的方法,使用使用的百分比和百分比,但没有任何意义,我很确定有一种简单的方法可以做到这一点,但我找不到它。
我的理想输出将是下面的文本,但我可能会在应用程序中格式化:
You have used X% of your [resource name] in Y% of the time allotted,
at this rate the resource will run down around [Run Down Date].
任何人都可以计算出这是如何计算的吗?
编辑:
为了尝试使问题更清楚,我将解释如何计算单个日期:
对于第一行 (ID = 1)。
Average % per day = Percentage (80.6) / Days between Start and Today (205)
Average % per day = 0.003931707%
% remaining = Percentage (80.6%)
% remaining = 19.4%
Days remaining = Average % per day (0.003931707%) / % remaining (19.4%)
Days remaining = 49.34243176
Project Run Down = Today + Days Remaining (49.34243176)
Project Run Down = 11/09/2012 (11th Sep)
我已尝试将此过程转换为 SQL,但无法正常工作。