I am working on a inventory table with a field of Estimated Years Life of the item. I would like to get the % Month Depreciation of the Estimated Years Life field.
SUPPLY_TABLE
Field SUPPLY_ITEM SUPPLY_LIFEYEARS GET_MONTHDEPRE_PERCENT(Desired-output)
Item A 20 0.41667%
Item B 5 1.66667%
I tried running a formula in excel for the % Month Depreciation of the Estimated Years Life field and it displays a correct data. But when I tried applying the formula in the select procedure it displays different and wrong result.
Excel formula = (1/(20*12))*100
This my sample select procedure
CREATE PROCEDURE AAAAAAAAAAA_SAMPLE
RETURNS(
SUPPLY_LIFEYEARS DECIMAL(12, 2),
GET_MONTHDEPRE_PERCENT DECIMAL(12, 5))
AS
BEGIN
FOR
SELECT
SUPPLY_LIFEYEARS,
(1/(SUPPLY_LIFEYEARS*12)) * 100
FROM SUPPLY A
INTO
:SUPPLY_LIFEYEARS,
:GET_MONTHDEPRE_PERCENT
DO
BEGIN
SUSPEND;
END
END;
Output of this select procedure (actual result)
SUPPLY_LIFEYEARS GET_MONTHDEPRE_PERCENT
20 0
5 1
Desired or expected output
SUPPLY_LIFEYEARS GET_MONTHDEPRE_PERCENT
20 0.41667%
5 1.66667%