Mastering SQL for Oracle Fusion HCM – Chapter 4 : SELECT Statement in SQL

 

✅ Chapter 4. SELECT Statement in SQL

SQL SELECT Statement – Read Data in Oracle Fusion HCM

Learn how to use the SQL SELECT statement with practical examples from Oracle Fusion HCM. Includes syntax, use cases, and real-time HCM queries.


๐Ÿ”น Introduction

The SELECT statement is the foundation of SQL. It allows you to retrieve data from one or more tables in a database. In Oracle Fusion HCM, you’ll use SELECT frequently to:

  • Build BI Publisher reports

  • Validate HDL data

  • Create SQL-based value sets

  • Analyze employee, job, and payroll information

This chapter will help you master the SELECT statement with real examples from Fusion HCM.

๐Ÿ”น Theoretical Concepts

๐Ÿ” Syntax of SELECT


SELECT column1, column2, ... FROM table_name [WHERE condition];

๐Ÿ“Œ Key Clauses

ClausePurposeExample
SELECTSpecifies which columns to returnSELECT full_name
FROMSpecifies the tableFROM per_all_people_f
WHEREFilters dataWHERE person_id = 1001
ORDER BYSorts resultsORDER BY full_name ASC
DISTINCTRemoves duplicatesSELECT DISTINCT department_id

๐Ÿ”น Example Queries in Fusion HCM

✅ Example 1: Basic Query from People Table


SELECT person_number,
       full_name,
       date_of_birth
FROM   PER_ALL_PEOPLE_F;

✅ Example 2: Filter Active Records

SELECT person_number,
       full_name,
       national_id
FROM   PER_ALL_PEOPLE_F
WHERE  TRUNC(SYSDATE) BETWEEN effective_start_date AND effective_end_date; 

✅ Example 3: Sort Alphabetically

SELECT full_name
FROM   PER_ALL_PEOPLE_F
ORDER  BY full_name ASC; 

✅ Example 4: Distinct Departments

SELECT DISTINCT department_id
FROM   PER_ALL_ASSIGNMENTS_M; 

๐Ÿ”น Real-Time Scenario (Fusion HCM Use Case)

๐Ÿงพ Scenario:

“You are asked to generate a list of currently active employees and their dates of birth, sorted by name.”

✅ SQL Query:


SELECT person_number,
       full_name,
       date_of_birth
FROM   PER_ALL_PEOPLE_F
WHERE  TRUNC(SYSDATE) BETWEEN effective_start_date AND effective_end_date
ORDER  BY full_name ASC; 

This type of query is used frequently in:

  • BI Publisher reports

  • HCM Extract filters

  • Validation of HDL loads


๐Ÿ”น Practice Exercise

๐Ÿ’ก Task:

Write a SQL query to fetch the assignment number, job_id, and department_id for all employees whose assignments are active today.

SELECT assignment_number,
       job_id,
       department_id
FROM   PER_ALL_ASSIGNMENTS_M
WHERE  TRUNC(SYSDATE) BETWEEN effective_start_date AND effective_end_date; 

๐Ÿ”น Best Practices

  • Always use effective_start_date and effective_end_date to get current data.

  • Avoid using SELECT * in production queries—list only required fields.

  • Use ORDER BY to ensure consistent results in reports.

  • Use DISTINCT carefully—can affect performance.


๐Ÿ”น Summary

✅ The SELECT statement is used to read data from HCM tables.
✅ Use clauses like WHERE, ORDER BY, and DISTINCT to control result sets.
✅ In Fusion HCM, effective dates are essential when selecting active records.
✅ Mastering SELECT is critical for BI Publisher and HDL-based validations.


๐Ÿ”น Next Steps

Tags: #SQLSELECT, #FusionHCM, #EmployeeData, #BIReports, #EffectiveDates, #OracleSQL

No comments:

Post a Comment