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 |
|
nhess80
Yak Posting Veteran
83 Posts |
Posted - 2009-08-21 : 16:45:42
|
| I know this should be easy but when I run this the results don't come out right. Also I am dividing the columns and they have been calculated separately.COUNT(*) AS AttemptCalls, COUNT(CASE WHEN Duration > '0' THEN '1' END) AS CompleteCalls, SUM(CONVERT(numeric(18), Duration) / 60) AS Duration, COUNT(CASE WHEN Duration > '0' THEN '1' END) / COUNT(*) AS ASROk so I would like the output to be for exampleAttemptCalls = 10CompleteCalls = 7Duration = 60ASR = 0.7The problem is when I run this the ASR column is only returning either a 1 or a 0 and I’m not sure why if the AttemptCalls = CompleteCalls a 1 is returned anything else it returns a 0Thanks for your helpNick |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-21 : 16:57:24
|
COUNT(CASE WHEN Duration > '0' THEN '1' END) / convert(decimal(12,2),COUNT(*)) AS ASR No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
nhess80
Yak Posting Veteran
83 Posts |
Posted - 2009-08-21 : 17:01:53
|
Thank you very muchquote: Originally posted by webfred COUNT(CASE WHEN Duration > '0' THEN '1' END) / convert(decimal(12,2),COUNT(*)) AS ASR No, you're never too old to Yak'n'Roll if you're too young to die.
|
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-21 : 17:02:58
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|