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 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2008-04-15 : 15:21:53
|
| I want to calculate rate as percentage using code below:SELECT OrderBy, NumShiped/Total AS Rate FROM OrderI always got Rate = 0 even thought NumShiped = 80 and Total = 100What is problem? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-15 : 15:27:02
|
| You need to convert one of them to decimal. 80/100 equals 0 when it comes to the integer data types.SELECT OrderBy, CONVERT(decimal(18,2), NumShiped)/Total AS Rate FROM OrderTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2008-04-15 : 15:34:13
|
| It is working. Thank you! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|