Issue with adjusting CAST in a calculation (precision)

  • Hello friends,

    I believe it should be an easy fix for someone who is good at casting. I appreciate your help.

    My calculation is :

    CAST(SUM(p.QTY) / SUM (r.QTY) AS decimal (5,2)) AS 'Forecast Accuracy'

    p.QTY - Forecast Demand

    r.QTY - Last Week Actual


    p.QTY = 2596

    r.QTY = 2504

    Therefore my calculation is

    2596/2504 = 1.04

    But I have 1.00 as a result

    There is an issue with precision I believe. Does someone know how I can adjust the so that the 4 is not dropped.

    Please let me know if you know.

    Thank you.

  • CAST(SUM(p.QTY * 1.0) / SUM (r.QTY) AS decimal (5,2)) AS 'Forecast Accuracy'

    by "forcing" one of the operators to be a decimal the results is now a decimal.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply