Subject | RE: [firebird-support] Re: Need SQL help for finding non-existant records |
---|---|
Author | Clay Shannon |
Post date | 2005-06-24T16:32:28Z |
>He meant to say 'the ON clause of the left join'
OK, this is what I've come up with, thanks to all the input:
select distinct h.fullname, s.shiftdate, p.pchin, p.pchout, s.shift_begin,
s.shift_end
from scheduled_work s
left join pchup p on (p.empno = s.empno) and
//first, find those who didn't punch it at all
(((p.pchin is null) and (p.pchout is null)) or
//the rest came late or left early
(cast(p.pchin as date) = s.shiftdate) and
((cast(p.pchin as time) > s.shift_begin) or
((cast(p.pchout as date) = s.shiftdate) and cast(p.pchout as time) <
s.shift_end)))
join empinfo_history h on h.empno = s.empno
order by h.fullname, s.shiftdate
Clay Shannon,
Dimension 4 Software