Hi -
I'm trying to join these two queries but apparently I don't know how to do a left join for them.
Select r.Eid, AcYear, dbo.idtoservice (s.srvcode)as service,rotatio n,max(pgy) pgy, startdate,endda te,
SUM(DATEDIFF(da y, StartDate, EndDate) + 1) AS daysworked
from Schedule s, ViewcurrentResi dents r
where s.eid=r.eid and s.stfgroup in (3,4)
and r.eid = 8119
group by r.eid, acyear, dbo.idtoservice (s.srvcode),rot ation,cast(righ t(degrcode,1) as tinyint), startdate, enddate
Select r.eid,acyear,ro tation,sum(date diff(day, datefrom, dateto)+1) daysoff
from vacation v, ViewcurrentResi dents r
where v.eid=r.eid
and r.eid = 8119
group by r.eid,acyear,ro tation
I really just need the last field (daysoff) in the second query to be joined to the first query - even when a record does not exist.
Please help.
Thanks,
Tenesha
I'm trying to join these two queries but apparently I don't know how to do a left join for them.
Select r.Eid, AcYear, dbo.idtoservice (s.srvcode)as service,rotatio n,max(pgy) pgy, startdate,endda te,
SUM(DATEDIFF(da y, StartDate, EndDate) + 1) AS daysworked
from Schedule s, ViewcurrentResi dents r
where s.eid=r.eid and s.stfgroup in (3,4)
and r.eid = 8119
group by r.eid, acyear, dbo.idtoservice (s.srvcode),rot ation,cast(righ t(degrcode,1) as tinyint), startdate, enddate
Select r.eid,acyear,ro tation,sum(date diff(day, datefrom, dateto)+1) daysoff
from vacation v, ViewcurrentResi dents r
where v.eid=r.eid
and r.eid = 8119
group by r.eid,acyear,ro tation
I really just need the last field (daysoff) in the second query to be joined to the first query - even when a record does not exist.
Please help.
Thanks,
Tenesha
Comment