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 |
|
interclubs
Yak Posting Veteran
63 Posts |
Posted - 2004-07-25 : 14:35:46
|
| I can't get this to work and its driving me nuts....I've simplified the stored proc for convenience sake, but basically its something like this:select (5/20 * 100) as SomeNum from some_Table where ID=1It should return 25, but instead it returns 0.....What am I missing here?Thanks! |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-07-25 : 14:56:46
|
| You need to declare one of the numbers in the division statemetn as a decimal so it can capture the .25. Otherwise, it looks at it as an integer, which when rounded nicely equals zero. :) 0*100 = 0select ((CAST(5 AS DECIMAL(5,2))/20) * 100) = 25MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|