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 |
|
mrsaif
Starting Member
43 Posts |
Posted - 2006-04-27 : 04:01:10
|
| I have a table "tbl_job_emails"job_id Job_date1 12/4/20052 12/5/2005.another table "tbl_send_emails"email_id, job_id, email_status_id1 1 12 1 13 1 24 1 25 2 16 2 2--------------------------------I want to count jobs by email_status_id(1 of sent 2 for not sent)I want this result by using on Query job_id sent not_sent1 2 22 1 2------------------------------------How should it do this in one query.regardSaifMuhammad Saifullah |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-27 : 04:04:34
|
| Select job_id, Sum(case when email_status_id=1 then 1 else 0 end) as sent,Sum(case when email_status_id=2 then 1 else 0 end) as not_sent from yourTable group by job_idMadhivananFailing to plan is Planning to fail |
 |
|
|
mrsaif
Starting Member
43 Posts |
Posted - 2006-04-27 : 04:14:30
|
| Thanks madhivanan It Realy Worked for me. :)Muhammad Saifullah |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-27 : 05:10:28
|
| Well. Read about Cross-tab Reports in sql server help file for more informationMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|