SELECT ISNULL(COUNT(*), 0) FROM kdtKalendarzIndywidualny kKI LEFT OUTER JOIN tblPracownicy tP ON tP.UID = kKI.UID_tblPracownicy WHERE tP.JK = [NUMER_JEDNOSTKI] AND (kKI.CzasPracyG IS NOT NULL AND kKI.CzasPracyG > 0) AND ( SELECT COUNT(*) FROM kdtKalendarzGodziny kKG LEFT OUTER JOIN kdsKodyCzasow kKK ON kKK.JK = tP.JK AND kKK.Kod = kKG.Kod WHERE kKG.UID_tblPracownicy = kKI.UID_tblPracownicy AND kKG.Data = kKI.Data ) = 0