Results 1 to 2 of 2

Thread: [RESOLVED] Problem with Decimal Places and Rounding off

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    829

    Resolved [RESOLVED] Problem with Decimal Places and Rounding off

    Good Day All

    i have a Following Query

    1) Query 1

    Code:
    DECLARE @FINALVAUE VARCHAR(MAX) =   (Convert(decimal,@CAUSATIVE_FACTORS_ID) - 1) +   Convert(decimal,@LU_PERCENTAGE_FAILURE_IN_SAMPLE_ID) + Convert(decimal,@LU_REPORTING_HISTORY_ID)  
    PRINT @FINALVAUE -- the answer is 3
    The Calculation is like this

    2) Query 2

    Code:
    DECLARE @FINAL VARCHAR(MAX) 
    SET  @FINAL=  (4-1) + 0.08 + 0.2
    SELECT @FINAL -- the asnwer is 3.28

    The first Query i am retrieving values from the Variables which are varchar and converting to decimal and doing the calculations. and the second Query i am just taking the value as is. i used this to debug in trying to solve this problem. My problem here in the first Query in the @FINALVAUE variable the answer is "3" and in the second Query the answer is "3.28"
    , i want the first Query to display the same value which is "3.28"

    Thanks

  2. #2

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    829

    Re: Problem with Decimal Places and Rounding off

    I resolved the Problem by using decimal(10,2)in all the conversions

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width