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 |
|
Trininole
Yak Posting Veteran
83 Posts |
Posted - 2010-02-24 : 09:11:19
|
| what is the syntax for calculating a percentage in sql?Roger DeFour |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-24 : 09:16:35
|
quote: Originally posted by Trininole what is the syntax for calculating a percentage in sql?Roger DeFour
There is no built-in function. You need to writevalue1/value2*100MadhivananFailing to plan is Planning to fail |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-02-24 : 09:24:42
|
| [code]declare @value1 MONEY=50declare @value2 money=10select convert(VARCHAR,@value1 * @value2 / 100) + '%' [/code]PBUH |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-24 : 09:27:28
|
| make sure you use 100.0 if operands are of type integer if you need to get decimal part in result.value1/value2*100.0------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|