Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: how to format a decimal number...

    Hi... i am a desperate newbie... i am trying to insert into a table some decimal values... but....

    INSERT INTO TT set xx = (yyy/zzzz)

    the field xx has decimal places but the division result has more decimals than it... so i need to format it in the sql, i must do it in the sql statement..

    is there any format number function?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: how to format a decimal number...

    Originally posted by angelitoz
    Hi... i am a desperate newbie... i am trying to insert into a table some decimal values... but....

    INSERT INTO TT set xx = (yyy/zzzz)

    the field xx has decimal places but the division result has more decimals than it... so i need to format it in the sql, i must do it in the sql statement..

    is there any format number function?
    I don't think formatting will help you here. If the result cannot be represented with the precision of the column you're trying to change then your only solution is to modify the column definition. If you're sure that the result will fit into the column you can try this:

    INSERT ... SET xx = DECIMAL(yyy/zzzz, p, s)

    where q and s are the precision and the scale of your target column, respecitvely.
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

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