June 26, 2006 at 6:07 pm
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
June 26, 2006 at 6:35 pm
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
Change is inevitable... Change for the better is not.
June 27, 2006 at 6:53 am
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
June 27, 2006 at 8:46 am
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
June 27, 2006 at 11:48 am
Thanks Everyone
October 8, 2015 at 12:06 pm
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