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 |
|
nt4vn
Yak Posting Veteran
98 Posts |
Posted - 2009-03-26 : 12:19:57
|
I got it work now..thanks for looking...I just add a count(*) to the main query ..instead of subquery...see below in red.-----------------------select count(distinct a.id_case) as NumNF_Referred, count(d.id_case) as NumNFPds,c.nm_org as agencyfrom dba.caseHistkITs aleft join (Select distinct id_case, id_org, min(dt_action) as AssignedDate, max(dt_action) as ClosedDate from dba.tf1casdeh where id_org between '1393' and '1399' group by id_case, id_org )b on b.id_case=a.id_caseinner join dba.tf1org c on c.id_org=b.id_orgleft join (select a.id_case, count(*) as NumNFPds from dba.tf1cpxref a inner join dba.tf1acper b on a.id_internal = b.id_internal and a.cd_type_acct = b.cd_type_acct and a.id_acct = b.id_acct and a.dt_pd_acct_begin = b.dt_pd_acct_begin and a.dt_pd_acct_end = b.dt_pd_acct_end where b.cd_status_pd<>4 group by a.id_case ) d on d.id_case=a.id_casewhere a.am_case_total=0and a.datecaptured between DateAdd(dd,-4, b.AssignedDate) And DateAdd(dd, 3, b.AssignedDate)group by agency, d.NumNFpds |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-26 : 12:56:12
|
| why don't you format your query and post again. Align your select, from, where etc. |
 |
|
|
|
|
|
|
|