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 |
|
BigJohnson
Starting Member
9 Posts |
Posted - 2006-07-25 : 07:16:45
|
| Hi allI'm trying to peform a quick percentage calculation which should return a multi-decimal placed integer - but it doesn't, it returns a rounded figure. How can I overcome this.= (100 * (sum1)) / (sum2)eg (100*(332) / 1390 = 23 (should be 23.88) |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-07-25 : 07:18:40
|
| (100.0 * (sum1)) / (sum2)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
BigJohnson
Starting Member
9 Posts |
Posted - 2006-07-25 : 07:30:23
|
| Simple, effective! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-25 : 07:32:07
|
"it returns a rounded figure"that's because 100, sum1 & sum2 are integer. When integer divide by integer the result will be an integer.What nr did is specifying a number with decimal 100.0. So decimal multiply by decimal value will result in decimal value and hence the result of the final calculation will also be in decimal. KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-29 : 06:47:33
|
| If you use variables in place of values then you can simply multiply it by 1.0((1.0*@var1*(@sum1))/(@sum2)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|