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 |
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-05-07 : 10:24:36
|
| Create Procedure TimeTest @cname varchar(50) asSelect(Case when count(*) = 0 thenCName,'First' as timerange,0 as earned,0 as wins,0 as losses,'0.0%' as pctElseCName,'First' as timerange, SUM(UE) as earned, SUM(case when result = 'win' then 1 else 0 end) as wins, SUM (case when result = 'loss' then 1 else 0 end) as losses, Str(1.0 * SUM(case when result = 'win' then 1 else 0 end) count(*) * 100,5,1) + '%' as pctEndFrom UniversalWhere CName = @cname and GTime > Convert(smalldatetime,'2003-05-01')Group ByCName</end code>I am more concerned about understanding what I am doing right as getting anything to work. Using the case statement at the beginning seems to fall in line with the case statements used with the SUM functions. And that code works. Thanks. |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-05-07 : 10:33:06
|
| John, Why do you keep posting on different threads?If you continue on the same post it will be easier to follow the discussion. See my last response to your previous post.http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25969Edited by - ValterBorges on 05/07/2003 10:33:34 |
 |
|
|
|
|
|
|
|