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 |
Leigh79
Starting Member
28 Posts |
Posted - 2007-10-31 : 07:58:26
|
Hi GuysI have a table which allows me to track which members of staff are capturing customers email addresses.I now want to produce a 'League Table' to show which are the best performing areas.The information stored in the table is id, staff_id, staff_dept, email_address.What I would like the end result to be isDepartment, Total Logged (COUNT of id), Total Real Addresses (COUNT OF id WHERE email_address <> 'NA'), Total Default Addresses (COUNT OF id WHERE email_address = 'NA')Can anyone tell me what is the best way to go about this? |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-10-31 : 08:08:52
|
[code]Select staff_dept as Department, sum(case when email_address <> 'NA' then 1 else 0 end) as [Total Real Addresses], sum(case when email_address = 'NA' then 1 else 0 end) as [Total Default Addresses]from TableGroup by staff_dept[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
Leigh79
Starting Member
28 Posts |
Posted - 2007-10-31 : 08:10:26
|
Hi HarshThat is exactly what I needed, thanks for your help, and fast response! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-31 : 08:22:55
|
Read about Cross-tab reports in sql server help file for more informationsMadhivananFailing to plan is Planning to fail |
|
|
|
|
|