Třídová akce

Kód:
3
Tělo:
select count(wi.id) 
  from WorkingInjuries WI
  join WorkingRelations WR on WR.ID = WI.WorkingRelation_ID
  join Employees EMP on EMP.ID = WR.Employee_ID
  where 
    WI.DateOfInjury$DATE >= :DateFrom and 
    WI.DateOfInjury$DATE <= :DateTo and
    (
      (:RegardBaseType = 'N') or
      ((:RegardBaseType = 'A') and (WI.BaseType IN ({BaseType})))
    ) and 
    (
      (:RegardRelevance = 'N') or
      ((:RegardRelevance = 'A') and (WI.Relevance IN ({Relevance})))
    ) and
    (
      (:RegardSicks = 'N') or
      (
        (:RegardSicks = 'A') and  
          (not exists (
              select SB.WorkingInjury_ID from 
                SickBenefits SB
                where SB.WorkingInjury_ID = WI.ID)
          )
       )         
    ) and
    ( 
      (:RegardEmployee = 'N') or
      ((:RegardEmployee = 'A') and {EMPCond})  
    
    )

Generated by ABRA Software a.s. 27.10.2021 16:34:36