CAST to DECIMAL rounds/returns figurelower than source

  • Hi guys,

    I have an anomaly I have never seen before.

    Casting a decimal (25,6) to decimal (18, 2 ) looses data

    the code is:

    sum(MSP_EpmAssignmentByDay_UserView.AssignmentActualWork ) srcAssignmentActualWork,

    SUM(CAST(MSP_EpmAssignmentByDay_UserView.AssignmentActualWork AS decimal(18,2))) AS AssignmentByDayActualWork

    the first line being the original source

    the results being:

    175.500000175.50

    172.000000172.00

    161.999994162.02

    146.000120145.86

    135.999990135.87

    168.000000167.79

    the bottom 4 lines return figures lower than the original.

    how is this possible and how can I fix it?

    Cheers

    Ian

    Ian Cockcroft
    MCITP BI Specialist

  • Ian

    What happens if you CAST after doing the SUM?

    John

  • That worked.

    thanks a mil John

    Ian Cockcroft
    MCITP BI Specialist

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

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