How to get count of active users grouped by operating unit and organization in oracle 11i.
select
haou.NAME ORGANIZATION,
h.NAME OPERATING UNIT,
count(distinct ppf.full_name) AS TOTAL
from
FND_USER FU,
per_all_people_f ppf,
hr_all_organization_units haou ,
hr_locations_all hlal ,
org_organization_definitions ood,
hr_operating_units h
where 1=1
AND FU.EMPLOYEE_ID=ppf.PERSON_ID
and ppf.BUSINESS_GROUP_ID = haou.BUSINESS_GROUP_ID
and hlal.LOCATION_ID = haou.LOCATION_ID
and ood.organization_id = haou.organization_id
and ood.operating_unit = h.ORGANIZATION_ID
AND FU.END_DATE IS NULL
Sample output:
OPERATING UNIT | ORGANIZATION| COUNT
XXXX | A | 2
XXXX| B| 3
XXXY|S| 4
XXXY| F| 5