HCM Query Cookbook

30 Oracle HCM SQL Queries
That Actually Work

Stop spending 3 hours on a query that should take 20 minutes. Copy-paste production SQL for PER_ALL_ASSIGNMENTS_M, headcount, compensation, absence, and turnover โ€” with every gotcha documented.

Get the Cookbook โ†’
Used by Oracle HCM consultants billing $150โ€“$350/hr. Not ChatGPT output โ€” real queries run on live environments.
30Production queries
8HCM modules covered
100%Date-effective safe
0Duplicate rows guaranteed
๐Ÿ˜ค

ChatGPT writes broken queries

Generic SQL generators don't know about EFFECTIVE_LATEST_CHANGE, _M vs _F tables, or ASSIGNMENT_STATUS_TYPE filters. You get 40 rows per employee.

๐Ÿ”

Oracle docs don't show joins

You can find the column names. You can't find which table to join, in what order, with which filters to avoid blowing up the result set.

โฑ๏ธ

Every query is a 3-hour debug session

Date-effective tables, future-dated rows, multiple assignment types, TL translation joins โ€” each one is a trap unless you've been burned before.

What's Inside

30 Queries Across 8 HCM Modules

Every query includes the full SQL, required filters, a column reference, performance notes, and common mistakes for that specific pattern.

01

Active Employee Headcount โ€” Single Row Guaranteed _M

PER_ALL_ASSIGNMENTS_M with EFFECTIVE_LATEST_CHANGE = 'Y' + ASSIGNMENT_TYPE = 'E' + active status. Zero duplicates, works on 100K+ employee orgs.

02

Point-in-Time Headcount (As-Of Any Date) SQL

Historical snapshot using PER_ALL_ASSIGNMENTS_F date-range filtering. Correct pattern for quarterly/annual HR reports โ€” not the same as current headcount.

03

New Hires vs. Rehires vs. Internal Transfers SQL

Distinguishes genuine new hires from rehires using ORIGINAL_DATE_OF_HIRE vs LAST_HIRE_DATE. Most teams get this wrong and inflate headcount reports.

04

Terminations with Reason Code and Final Dept SQLPERF

ACTUAL_TERMINATION_DATE + termination reason from PER_PERIODS_OF_SERVICE. Includes voluntary vs. involuntary classification and last assigned cost center.

05

Turnover Rate by Department (Rolling 12-Month) SQL

Annualized turnover with beginning headcount denominator. Correct formula that matches what your CFO expects โ€” not just count of terminations.

06

Employee Manager Hierarchy (3 Levels) SQL

Self-join on MANAGER_ID with NULL handling. Supports orgs where managers have multiple assignment types at each level.

07

Assignment History Audit Trail SQL_M

Full date-effective change log per employee: what changed, when, and prior value. Required for compliance and SOX audit responses.

08

Current Base Salary with Grade and Compa-Ratio SQL

CMP_SALARY join with assignment and grade tables. Handles currency conversion flag and salary range midpoint for compa-ratio calculation.

09

Salary Change History (All Increases and Decreases) SQL

Date-effective salary history with previous salary, change amount, and change reason. Covers merit, promotion, and market adjustment events.

10

Compensation Equity Analysis by Job and Gender SQLPERF

Average, median, min/max salary by job code and gender. Pay equity report-ready. Uses PERCENTILE_CONT for true median in Oracle SQL.

11

Absence Balance by Plan Type SQL

Vacation, sick, and PTO balances from ANC_PER_ACCRUAL_PLANS. Correct table โ€” not the view. Handles absence plan version changes.

12

Absence Transactions โ€” Who Took What SQL

ANC_PER_ABSENCE_ENTRIES with absence type, start/end dates, and approved/pending status. Includes calendar days vs. working days distinction.

13

Open Job Requisitions by Department SQL

IRC_REQUISITIONS with status filter for open roles. Includes requisition age, hiring manager, and department cost center for budget tracking.

14

Candidate Pipeline โ€” Stage Breakdown SQL

IRC_SUBMISSIONS with phase/state mapping. Shows funnel from Applied โ†’ Screened โ†’ Interview โ†’ Offer โ†’ Hired for each requisition.

15

Time-to-Fill by Requisition SQL

Days from requisition open to offer accepted. Uses TRUNC(SYSDATE) anchor date, handles requisitions with multiple offers.

16

Payroll Element Results by Period SQL

PAY_RUN_RESULTS + PAY_RUN_RESULT_VALUES for a given payroll period. Correct join to avoid exploding row counts on multi-element assignments.

17

Tax Withholding Amounts by Employee SQL

Federal, state, and local withholding from PAY_RUN_RESULTS filtered by element classification. Year-to-date accumulation pattern included.

18

Benefits Enrollment โ€” Current Elections SQL

BEN_PRTT_ENRT_RSLT_F with plan and option joins. Shows medical, dental, vision, and 401k elections for open enrollment audits.

19

Goal Status and Completion Rates SQL

HRA_OBJECTIVES for performance goals. Completion percentage, due dates, and manager-assigned vs. self-assigned goal breakdown.

20

Performance Rating Distribution SQL

HRA_EVALUATIONS with rating scale mapping. Shows distribution by department and level โ€” the query your CHRO asks for every review cycle.

21

Learning Completion by Course SQL

WLF_LEARNER_ATTEMPTS with completion status. Compliance training audit โ€” shows who completed, who's overdue, and completion date for each mandatory course.

22

Workforce Diversity Report SQL

Headcount by gender, ethnicity (EEO categories), age band, and disability status. EEO-1 report prep. Handles null demographic values correctly.

23

Span of Control (Direct Reports per Manager) SQL

Manager headcount with organizational level depth. Identifies managers with 1 direct report and managers with 20+ for org design analysis.

24

Workforce Location Report SQL

Employees by work location including remote/hybrid flag. Uses PER_LOCATIONS join with HR_LOCATIONS_V for address details.

25

Pending HR Transactions (Approval Queue) SQL

Pending actions from HRA_DOCUMENT_CATEGORIES and approval workflow tables. Shows what's stuck in approval and who needs to act.

26

HDL Load Audit โ€” What Changed After a Load SQL

Before/after comparison using LAST_UPDATE_DATE filter. Quickly confirms which rows were touched by a specific HDL batch load.

27

Flexfield (DFF) Values by Employee SQL

PER_ALL_PEOPLE_F ATTRIBUTE columns with FND_DESCRIPTIVE_FLEXS lookup for meaningful names. Common ask: "show me the custom field we added in implementation."

28

Lookup Code Values for a Given Type SQL

FND_LOOKUP_VALUES with language filter. Returns all valid values for any HCM lookup type โ€” essential when building data validation reports.

29

Security Role Assignments by User SQL

ASC_ROLE_ASSIGNMENTS + FND_USERS + FND_MENUS. Shows who has what Oracle HCM security role โ€” standard ask during SOX or access reviews.

30

Data Quality Scorecard โ€” 8 Validation Checks SQLPERF

Eight data quality checks in one query: employees without jobs, assignments without cost centers, missing termination dates, future-dated rows, and more. Run before every audit.

Sample

This Is What You Get

Every query is fully commented, with filters explained and gotchas called out in-line.

Query #1 โ€” Active Headcount (zero duplicates)
-- Headcount: one row per active employee, guaranteed.
-- _M table + EFFECTIVE_LATEST_CHANGE handles future-dated rows automatically.
SELECT
  p.full_name,
  a.assignment_number,
  a.department_id,
  a.location_id,
  a.job_id,
  a.grade_id
FROM  per_all_assignments_m  a
JOIN  per_all_people_f       p  ON p.person_id = a.person_id
                                AND p.effective_start_date <= SYSDATE
                                AND p.effective_end_date   >= SYSDATE
WHERE a.effective_latest_change  = 'Y'        -- one row per assignment
  AND a.assignment_type          = 'E'        -- employees only (not CWK)
  AND a.assignment_status_type    = 'ACTIVE_ASSIGN'
  AND a.primary_flag             = 'Y'        -- primary assignment only
ORDER BY p.full_name;
Included

Everything You Need to Run These Queries

Not just the SQL โ€” the context that makes it work in your environment.

โœ“

30 production SQL files โ€” one per query, named and organized by module

โœ“

Required filters documented โ€” for every query, which columns you must include to avoid garbage results

โœ“

Column reference tables โ€” the 10โ€“15 most useful columns per query, with data types and notes

โœ“

Gotchas documented โ€” the traps that cost you hours the first time you hit them

โœ“

_M vs _F decision guide โ€” which table to use and when, with date-effective pattern comparisons

โœ“

Performance notes โ€” which queries need hints, which indexes to create, what blows up on large orgs

โœ“

OTBI Logical SQL equivalents โ€” for 10 key queries, the OTBI version that runs in Reports and Analytics

โœ“

Lifetime updates โ€” new queries added as Oracle releases new tables and schema changes (24B, 25A, etc.)

Pricing

Pick Your Option

Oracle HCM consultants bill $150โ€“$350/hr. These queries pay for themselves in the first use.

HCM Query Cookbook
$197
One-time ยท instant download
  • 30 production SQL queries
  • 8 HCM modules covered
  • Filters + gotchas + column refs
  • OTBI equivalents for 10 queries
  • _M vs _F decision guide
  • Lifetime updates included

30-day money-back guarantee. No questions asked.
FAQ

Common Questions

What Oracle versions do these queries support?

All queries target Oracle Fusion Cloud HCM 23D and later. Where a query differs between 23D and earlier releases, both versions are included. The PER_ALL_ASSIGNMENTS_M queries specifically cover the 24A/24B schema changes.

Do I need SQL developer access to run these?

Yes โ€” these are direct SQL queries against the Oracle HCM schema. You need either SQL Developer or access to Reports and Analytics (BIP/OTBI) with the appropriate HCM security roles. Ask your Oracle DBA for read access to the HCM schema if you don't have it.

Will these work with OTBI (Reports and Analytics)?

10 of the 30 queries include the OTBI Logical SQL equivalent. The remaining 20 are direct SQL that run via BI Publisher or SQL Developer โ€” OTBI has limitations that prevent some complex joins and window functions.

What if a query doesn't work in my environment?

Oracle HCM schemas vary by implementation, and some tables may have been customized or renamed. If a query doesn't run as-is, email me the error and I'll help you adapt it โ€” that's covered by the 30-day guarantee.

What's in the 30-min consulting call (bundle only)?

You bring 1โ€“2 specific reporting problems or queries you're stuck on. We walk through them together, I help adapt the cookbook patterns to your specific setup, and the session is recorded so you can reference it later.

How is this different from the OTBI Template Pack?

The OTBI Template Pack ($97) focuses on 15 OTBI report patterns with Logical SQL syntax. The HCM Query Cookbook ($197) is broader โ€” 30 queries, SQL + OTBI coverage, and every major HCM module including payroll, benefits, and performance. They're complementary, not duplicates.

Stop debugging. Start reporting.

30 queries that work on the first run. The alternative is another 3-hour debug session at 10pm before a stakeholder presentation.

Get the Cookbook โ†’
$197 one-time ยท instant download ยท 30-day guarantee