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 |
matkwan
Starting Member
36 Posts |
Posted - 2002-07-24 : 10:26:36
|
Hi I am having trouble creating a SQL to return me the Won % in each of the month. Can you please Help ?ID, Status, Date1, Won, 1 Jan 20022, Won, 1 Jan 20023, Lost, 5 Mar 20024, Lost, 7 Apr 20025, Lost, 4 Jan 20026, Won, 8 Mar 2002I want the end result to be:Won, Month66.66%, Jan50%, Mar0%, AprThanksMatthew |
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-07-24 : 14:29:43
|
select 100.0 * sum(iif(status='Won',1.0,0.0))/sum(1.0) , month([date]),year([date]) from tgroup by month([date]),year([date]) |
 |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-09-10 : 15:23:24
|
Boy, I love SQLTeam! I was working on a GROUP BY with Percentage calculation, and I was SOOOoooooo close, but just couldn't get it to pop. Then I thinks to myself... "You know, I'm sure I've seen this discussed in the SQLTeam forums. I think I'll go do a search." And sure enough, LarsG had a solution here for Access, and I already had the right CASE structure for SQL, so it was an easy mod.So just thought I'd post a Thanks to ALL! |
 |
|
|
|
|
|
|