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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Count multiple fields by month

Author  Topic 

phil2580
Starting Member

2 Posts

Posted - 2012-11-26 : 05:01:24
Hi,

I'm a bit stuck on this one...can anyone help please?

I've got a table (DW_Client) with a couple of status fields (Approved, Rejected), and a date field(CMDate). PK for each client is (C_UID)

I need to write a query that counts how many Clients were approved and rejected in each month, and the total number of Approvals submitted (Approval requests may cross the month boundary, so it's expected that Approved+Rejected won't total the number of requests)

| Month | Approved | Rejected | Total Requested |
| Jan | 21 | 3 | 42 |
| Feb | 20 | 6 | 28 |
| Mar | 12 | 1 | 19 |

and so on....


Thanks,

Phil

phil2580
Starting Member

2 Posts

Posted - 2012-11-26 : 05:22:34
I've cracked it :)
Go to Top of Page
   

- Advertisement -