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 |
|
Shelly1
Starting Member
25 Posts |
Posted - 2010-02-18 : 06:02:57
|
Hi all,I am trying to calculate the percentage of the following:[ARefd] =sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end),[TotalARefd] =sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end),[%_Refd]If anyone can help that would be great thanks Mich |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-18 : 06:08:38
|
quote: Originally posted by Shelly1 Hi all,I am trying to calculate the percentage of the following:[ARefd] =sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end)*100.0/count(1),[TotalARefd] =sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end)*100.0/count(1),[%_Refd]If anyone can help that would be great thanks Mich
modify like above and see------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Shelly1
Starting Member
25 Posts |
Posted - 2010-02-18 : 06:25:18
|
| Sorry possibly my description is misleadingI want to divide the ARefd by the TotalARefdIf i were to do a calculation on the calculator it would be ARefd/TotaARefdSorry if i have misleaded you.ThanksMich |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-18 : 06:47:11
|
| [code]sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end)*1.0/sum (case when Priority ='red' or Priority ='purple' and TimeArrived is null then 1 else 0 end)[/code]use 100.0 instead of 1.0 if you need it in percentage------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Shelly1
Starting Member
25 Posts |
Posted - 2010-02-18 : 07:34:28
|
| Thanks you very much that is great.Mich |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-18 : 07:35:20
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Shelly1
Starting Member
25 Posts |
Posted - 2010-02-22 : 05:14:15
|
| Thank you very much for that,Mich |
 |
|
|
|
|
|