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 |
|
WelshPunk
Yak Posting Veteran
67 Posts |
Posted - 2008-05-01 : 01:29:27
|
| The formula for percentage safe = sum(safe)/ sum(safe)+sum(unsafe)*100.0This works well on a calculator. Could someone show me how to achieve this in sql please. If we use safe = 92 and unsafe = 117This forum is great!Regards Phill |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-01 : 01:42:53
|
| SELECT PercentSafe=SUM(Safe)* 100.0 /(Sum(Safe) + Sum(unsafe)) From YourTable |
 |
|
|
WelshPunk
Yak Posting Veteran
67 Posts |
Posted - 2008-05-01 : 03:41:37
|
| Brill thanks for that. Is there a way of rounding the output to 2 decimal place |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-01 : 03:55:26
|
| select PercentSafe=convert(decimal(18,2),SUM(Safe)* 100.0 /(Sum(Safe) + Sum(unsafe))) From YourTable |
 |
|
|
WelshPunk
Yak Posting Veteran
67 Posts |
Posted - 2008-05-01 : 05:11:00
|
| Thank you |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|