Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ianwaters
Starting Member
2 Posts |
Posted - 2007-09-19 : 04:54:28
|
| Hi im using SQL server 2000 sp4i have a table with a column of type float called [veh yrs]none of the entries are null but when i run:select sum([veh yrs]) as [veh yrs sum] from [testtable]sum gives an incorrect value.[testtable][veh yrs]-0.931506849315068441.0027397260273974[veh yrs sum]7.1232876712328919E-2why is [veh yrs sum] 7.1232 ???Many Thanks for your help |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-19 : 04:59:22
|
This is formatting problem. Use Convert() to convert result to NUMERIC data typeSelect Convert(Numeric(25,6), sum([veh yrs])) as [veh yrs sum] from [testtable] Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-19 : 05:01:00
|
Because it is using scientific notation.The E-2 at the very end denotes that the number 7.1232E-2 stands for -27.1232 * 10 which is 0.071232876712328919 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ianwaters
Starting Member
2 Posts |
Posted - 2007-09-19 : 05:09:22
|
| Thanks guys you have saved me a couple of hourssearching!i hadnt tried CONVERT but it worksThanks again! |
 |
|
|
|
|
|