Divide by 2.1 Billion

  • Hello everyone. I have a table that tracks meter information and I need to divide the field by 2.1 billion. Is there a way to divide by scientific notation? or is there a better method to do this.

     

    Thank you,

     

    Matt

  • How big is the numerator?  Do you want the quotient with or without decimal places?  If so, how many do you want or are you willing to put up with the inaccuracies of the FLOAT or REAL datatypes?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Try the link below for all the T-SQL math functions in SQL Server 2005 most require Float data type.  Hope this helps.

    http://msdn2.microsoft.com/en-US/library/ms177516.aspx

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • To expand on previous posts: Numerics don't have a format (until they are turned into strings, i.e. not numeric), so in that sense your request for division in scentific notation is misconceived. However, float is very possibly what you are after.

    One point of using scientific notation is to ensure a certain degree of precision (number of significant figures) regardless of scale. That is what float does, too: you specify how precise (how many decimal places) you want the mantissa/significand to be, then that coefficient is stored alongside an exponent, which effectively tells the program how many positions to the right the decimal point is to be moved. So if you can afford imprecise (rounded) data, then float sounds right.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • Thanks Everyone

  • You will need to convert to numeric and use a decimal(38.2) conversion.

    convert(decimal(38,2),convert(decimal(38,2),sum(cast([Field] as numeric))) / convert(decimal(38,2),count(*))) as Total

Viewing 6 posts - 1 through 5 (of 5 total)

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