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 2005 Forums
 Transact-SQL (2005)
 How do I do an inline view to force a 0 count

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2007-06-13 : 13:09:05
I am using the statement bellow to get the following counts.

18 Annual JacksonDivision
1 Probation JacksonDivision
17 Annual MinnieDivision

However I want to force a 0 for those area's that have no count.
How do I do that. In oracle I could use and inline view and outer join it. How do I perform this here

example

18 Annual JacksonDivision
1 Probation JacksonDivision
17 Annual MinnieDivision
0 Probation MinnieDivision

select count(d.eval_type) as evalcount,d.eval_type,dorg.org_name as divname from due_evals d,emp_information_test e,new_organization dorg
where(e.empid = d.empid And payloc_comp_date Is NULL)
and datetobefiled between '09/01/2001' and '05/31/2007'
and e.division in (select division from ceo_email where empid = 000000)
and e.dIvision = dorg.org_id and dorg.type = 'DIVISION'
group by d.eval_type,dorg.org_name order by divname,d.eval_type

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-06-13 : 13:13:13
use left join

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

rudesyle
Posting Yak Master

110 Posts

Posted - 2007-06-13 : 13:41:02
quote:
Originally posted by spirit1

use left join

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp



Yeah, left join and then a call to the isnull function in cases where the count is null
Go to Top of Page
   

- Advertisement -