luvtitans50
MIS
I have a query that I am doing a left outer join on and it returns rows with all "0" and I don't want those to show; how can I do about doing this? I tried doing something like:
a <>0 or b <> 0 or c <> 0 but that eliminates needed data?
select
clientname, c.clientid,
isnull(s.servicelinedescription,'Other') as serviceline,
'newpositions' = isnull(a.newopenings,0),
'Submittals' = submittals,
'totalheadcount' = headcount,
'unfilledpositions' = Case when a.newopenings < totalactive then 0
else a.newopenings - totalactive end,
'numerator' = ontime,
'fills' = fills,
'timetofill' = timetofill,
'newopenings' = newopenings,
'totalactive' = b.totalactive,
'futurepositions' = futurepositions,
latefilledpositions,
earlyfilled
from clients c
left join
--get orders that started this month
(
select clientid,
sum(case when o.startdate between @startdate and @enddate then originalopenings else 0 end) as newopenings,
sum(case when o.startdate > @enddate then originalopenings else 0 end) as futurepositions,
COUNT(Case when o.startdate between @startdate and @enddate then orderid end) as totalorders
from orders o
where o.statusid in (144,157) --only include open or filled orderse
and
o.startdate IS NOT NULL
group by clientid
)a on a.clientid = c.clientid
a <>0 or b <> 0 or c <> 0 but that eliminates needed data?
select
clientname, c.clientid,
isnull(s.servicelinedescription,'Other') as serviceline,
'newpositions' = isnull(a.newopenings,0),
'Submittals' = submittals,
'totalheadcount' = headcount,
'unfilledpositions' = Case when a.newopenings < totalactive then 0
else a.newopenings - totalactive end,
'numerator' = ontime,
'fills' = fills,
'timetofill' = timetofill,
'newopenings' = newopenings,
'totalactive' = b.totalactive,
'futurepositions' = futurepositions,
latefilledpositions,
earlyfilled
from clients c
left join
--get orders that started this month
(
select clientid,
sum(case when o.startdate between @startdate and @enddate then originalopenings else 0 end) as newopenings,
sum(case when o.startdate > @enddate then originalopenings else 0 end) as futurepositions,
COUNT(Case when o.startdate between @startdate and @enddate then orderid end) as totalorders
from orders o
where o.statusid in (144,157) --only include open or filled orderse
and
o.startdate IS NOT NULL
group by clientid
)a on a.clientid = c.clientid