Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
Why is a Float Computed Column storing only 2 columns? |
Wed, Sep 19 2012 1:26 PM | Permanent Link |
Barry | I have 3 columns in the table:
Net_Weight Integer Net_Income Decimal 2 decimals Net_Income_Per_Kg Float Net_Income_Per_Kg computed with: "Net_Income_Per_Kg" FLOAT COMPUTED ALWAYS AS Net_Income / Net_Weight Even though Net_Income_Per_Kg is a Float, it stores only 2 decimals, probably because the greatest # of decimals in the computation (Net_Income) has only 2 decimals. Is there a way to force Net_Income_Per_Kg to store 3 decimal places? TIA Barry |
Wed, Sep 19 2012 1:50 PM | Permanent Link |
Fernando Dias Team Elevate | Barry,
It's because the expression (Net_Income / Net_Weight) is of type DECIMAL(19,2), as Net_Income is a DECIMAL, and Net_Weight is INTEGER - only after the computation the result is converted to FLOAT. You can force force it to be of type DECIMAL(19,3): "Net_Income_Per_Kg" FLOAT COMPUTED ALWAYS AS CAST(Net_Income AS DECIMAL(19,3)) / Net_Weight or even FLOAT: "Net_Income_Per_Kg" FLOAT COMPUTED ALWAYS AS CAST(Net_Income AS FLOAT) / Net_Weight -- Fernando Dias [Team Elevate] |
Wed, Sep 19 2012 2:22 PM | Permanent Link |
Barry | Fernando,
That worked, thanks. Barry |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |