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 |
|
michaelxvo
Starting Member
47 Posts |
Posted - 2007-03-09 : 13:23:26
|
| I have a table aTABLE Atotal_count SMALLINT,total_success SMALLINT,success_ratio DECIMAL(9,7)when I use this queryUPDATE TABLE ASET success_ratio = total_success / total_countthen I issue this query "SELECT * FROM A"what I see is either 1.0000 or 0.0000 in the success_ratio columnI am suppose to see something like 0.6666 or 0.33333 How can I convert two smallint to make a decimal result |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-03-09 : 13:32:28
|
| convert to decimal, also, watch out for the division by zero error and null valuesconvert(decimal(18,4),total_success)/convert(decimal(18,4),total_count)HTH--------------------keeping it simple... |
 |
|
|
michaelxvo
Starting Member
47 Posts |
Posted - 2007-03-09 : 13:41:01
|
quote: convert(decimal(18,4),total_success)/convert(decimal(18,4),total_count)
I got it workingthank you |
 |
|
|
|
|
|