Operation Details
Description:  
Sterotype: ns
SQL
SELECT
  COUNT (Position.positionID)
INTO
  :count
FROM
  OrganisationUnit,
  Position 
  
  LEFT OUTER JOIN
  
  
  ( 
  SELECT
    PositionHolderLink.positionID,
    COUNT(*) AS PHLcount 
  FROM
    PositionHolderLink 
  WHERE PositionHolderLink.organisationStructureID = :organisationStructureID 
    AND PositionHolderLink.recordStatus = :recordStatus 
    AND PositionHolderLink.fromDate <= :effectiveDate 
    AND 
    (
      PositionHolderLink.toDate >= :effectiveDate 
      OR PositionHolderLink.toDate IS NULL 
    ) 
  GROUP
    BY PositionHolderLink.positionID 
  ) VPHL 
  ON Position.positionID = VPHL.positionID,
  OrgUnitPositionLink,
  Job 
WHERE OrgUnitPositionLink.organisationStructureID = :organisationStructureID 
  AND OrgUnitPositionLink.organisationUnitID = OrganisationUnit.organisationUnitID 
  AND OrgUnitPositionLink.positionID = Position.positionID 
  AND Job.jobID = Position.jobID