BIP – Query to find number of work relations in a legal employer

There are different requirements where one wants to get number of active/inactive work relationships in a legal entity.

Below SQL query can be run to get these counts:

select, count(ppos.period_of_Service_id) number_of_wrs 
  from per_legal_employers ple
      ,per_periods_of_service ppos
 where ppos.legal_entity_id = ple.organization_id
 group by
 order by 1