Académique Documents
Professionnel Documents
Culture Documents
PEOPLESOFT
QUERY
1
Revised: August 2008
OVERVIEW
PeopleSoft Query
Basic ad hoc reporting tool
Allows you to write ad hoc queries and also run queries
shared by others
Allows data to be extracted to Excel
BASIC QUERY
Six steps to creating a basic query
1. Select the data record(s)
2. Select the field(s)
3. Set the query criteria
4. Edit the field properties (optional)
5. Save the query (optional)
6. Run the query
SAVED QUERY
You can access and run queries that you or others have
saved in the past
Public Queries are queries that you (or others) have saved which are
accessible by anyone
Private Queries are queries that you have saved which are only accessible by
you
NAVIGATING TO QUERY:
Note:
The list of query names & descriptions
Ownership (Public or Private)
Edit, Run to HTML, and Excel hyperlinks
You can open an existing query by clicking on the Edit hyperlink for the query you want to
run
Using the Action drop down box you can delete, move to folder, rename or copy a query to
someone else
Do NOT delete or rename a query that was created by someone else
Click on EMP_LIST_SEN_BRTH_JMS
8
Query Results:
10
Wow!
11
Click the HTML hyperlink for the query you want to run
12
Query Results
Navigate to:
- Reporting Tools > Query > Query Manager
- Click on Create New Query
14
Record Selection
Enter Personal in the search box to find the Personal Data record
15
NOTE:
Record name description
Add Record hyperlink to select the record for this query
Show Fields hyperlink to view the fields in the record
Find the PERSONAL_DATA record & click Add Record
16
Note:
Folder icon
Alias Record
Hierarchy Join
Minus Button
Fields:
Check box(es)
Key Symbol
Field names
Criteria icon
Join Record Names
17
18
Agg
Heading Text
Add Criteria
Edit
Delete
19
Select Edit
20
Aggregate values
Translate Value
None
Short
Long
21
22
Click on Reorder/Sort
Move Birthdate to Col 3
In the New Order By column: Make Sex sort order 1
Click OK
23
The query tool automatically generates SQL (Structured Query Language) code
SQL will look familiar to those of you who wrote queries in the past using QMF and is useful
for advanced users in troubleshooting problems with a query.
25
Saving Queries
Enter:
Query Name
Description
Owner
Private
Public
26
Naming Standards
Descriptive name
27
Enter:
Query Name: OX_GBLCO_EE_LIST_INITIALS
Description: General Info About Employees
Owner: Public
Click OK
Then click the Properties link (at bottom)
28
29
30
31
32
Key Points
For translate fields, the long or short descriptions can be displayed rather than the code
The SQL statement generated by a query can be viewed by selecting the View SQL tab
(for advanced query users)
33
Individual Activity #1
You have been asked to create a query that displays the hire and termination dates of all
employees and eliminate duplicates (see page 29).
Record
EMPLOYMENT
Fields/Headings
EMPLID
Employee ID
HIRE_DT
Hire Date
TERMINATION_DT
Termination Date
LAST_DATE_WORKED
SUPERVISOR_ID
Supervisor ID
Order by
TERMINATION_DT
descending
Query Name
HIRE_TERM_QRY
34
35
Individual Activity #2
You have been asked to produce an updated list of employees emergency contacts.
Record
EMERGENCY_CNTCT
Fields/Headings
EMPLID
Employee ID
CONTACT_NAME
Contact Name
RELATIONSHIP
PRIMARY_CONTACT
Primary Contact
PHONE
Phone
Order by
EMPLID
CONTACT_NAME
Query Name
EMER_CNTCTS
36
Selection Criteria
Next, we will add criteria rows to a query to return specific rows of data
38
Selection Criteria
Create a basic query to capture employee data and save the query without
running it.
Record
PERSONAL_DATA
Fields
NAME
EMPLID
MAR_STATUS
Order by
NAME
Query Name/Description
CRITERIA
(short description)
39
When youre ready, click the Criteria tab and then the Add Criteria button.
40
Expression 1:
Select the field (or Expression) you want
to compare
Field
Expression
Next well consider Condition Type
41
Condition Types
Between
Not between
Equal to
Not equal to
Greater than
In list
Not in list
In tree
Not in tree
Is null
Is not null
Less than
Like
Not like
42
43
44
45
You can apply criteria to fields that are not included in the query output
You need to know how the data is stored in the database to ensure accurate results
when the query is run
46
RESULTS
47
In addition to your current criteria, we now want to narrow the selection to retrieve only
those employees who have the capital letter D in their first name, middle initial or last
name.
48
Expression 2: %D%
Click OK
49
Click Save
Click Run
NOTE the Logical drop down list (And/Or) for your criteria
50
RESULTS
You now have a female employees who have a capital D in their name
51
Individual Activity #3
Produce a list of all employees whose Business Title contains the word Manager. Also,
only show those who were hired after 1989.
Record
EMPLOYMENT
Fields
EMPLID
BUSINESS_TITLE
HIRE_DT
Order by
HIRE_DT
(descending)
Business_Title
52
Results:
NOTE: Some fields are case sensitive which will impact your results
53
Criteria page
54
Effective Dates
Effective dated records are those records that contain the field EFFDT.
History
Rows of data where the Effective Date is less than the Effective
Date of the current row.
Current
Future
55
Effective Dates
When you start a new query and select an effective-dated record/data table, a dialog box
will display informing you that an effective-date criteria row has been automatically
created.
56
Effective Dates
Record: JOBCODE_TBL
57
58
Do Not Use:
First Effective Date
Last Effective Date
59
Individual Activity #4
Create a query that lists the last current job actions as of the current date for your employees.
Record
JOB
Fields/Headings
EMPLID
ID
DEPTID (column 2)
Dept ID
JOBCODE
Job Code
Action
ACTION_REASON
Reason
EFFDT
Effective Date
LOCATION
Location
ANNUAL_RT
Annual Rate
Order by
EMPLID
Criteria
Query Name
OX_BN_CUR_ACTION_XX
60
Fields tab
61
Criteria tab
62
Results
63
64
Build a very simple query to list Employee IDs for employees in the
PERSONAL_DATA record (or data table)
Record: PERSONAL_DATA
Fields:
EMPLID
Query Name: EMPLNUM
Save
65
66
67
Results
NOTE: Only one row is returned with a count of the number of Employee IDs.
68
Advanced Topics
Multiple Table Queries
Prompted Queries
Writing Expressions
69
PeopleSoft Query Manager allows you to join data from more than one
record/Data Table
You can join multiple records using the web-based Query Manager
70
Records listed in the Record Search may represent either a Table or a View.
A Table physically stores specific data.
A View is a compilation of data that is usually retrieved from multiple tables. This can
be considered as pre-joined tables.
Some Views may already have criteria associated with them.
71
Joins
A join allows you to retrieve data from two or more records/Data Tables -or- specify
criteria from more than one record/table
Whenever you perform a join, the records are linked based on common fields.
72
Types of Joins
Record
Hierarch
Related
Record
A Hierarchical join uses records that are parents or children of each other.
The hierarchical relationship is defined by the Parent Record in the
Application Designer.
Example: Joining employee Personal data with Dependent/Beneficiary data.
73
Join Example
Create the following new Query:
Record
Person_Name
Fields
Emplid
Name
74
FIELDS Tab
76
The Emplid (Key in both records) fields are automatically linked together to join
the Person_Name record with the Job record
Click on the Add Criteria because this is the join you want.
77
The job record has become part of the query and is joined to the Person_Name
record.
NOTE: The Alias ID for the Person_Name data table is A and the Alias ID for the
Job data table is B.
78
Control tables are shared by all divisions and sometimes need to be joined using
multiple keys or fields.
Many control tables have a Setid field that is used to match the Setid for the division
accessing the table.
Most control tables also have an Effective Date that should be considered when
joining to another base table.
80
Many fields that have associated tables have a link next to them that allows the user
to click and automatically join this table to this field.
In this example we will join the Location_Tbl control table to the Location field in
the Job record.
Click on the Join LOCATION TBL link & click OK to the pre-selected join.
81
Now the three tables are joined together (Person_Name, Job & Location_Tbl).
Select the DESCR Field in the Location table and go to the Criteria tab in the query.
82
Here you see that the base tables have been joined together and the Effective Dates are set
to look at the most current row in the record. Because you used the join link for the location
table you do not see the joining of the location field in job with the location field in the control
table. However, it is done automatically for you in the background. This can be seen if you
look at the SQL tab.
NOTE: Because it is a control table, a manual join of the Setid should be done to eliminate
the chance of duplicate values for the same field.
83
Select the Criteria tab & click on the Add Criteria button to create a new criteria to join the
Setid field in the Location record with the Setid for location in the Job record.
The fields to be joined are shown in the example above.
84
86
Prompted Queries
PeopleSoft Query allows you to build reports that contain runtime prompts.
A runtime prompt allows you or another user to enter a value for a specific field at the time
the query is run.
The report will display only those data rows that match the criteria entered in the prompt.
This makes the query dynamic, allowing it to be used over and over again without
modifying the query to meet changing requirements.
87
Runtime Prompts
Create the following query to retrieve employee disability election information.
Record
DISABILITY_BEN
Fields
EMPLID
PLAN_TYPE
(short description)
COVERAGE_BEGIN_DT
COVERAGE_ELECT
(short description)
BENEFIT_PLAN
Order by
EMPLID
Query name
DISABILITY
88
89
Results
90
A prompt is another type of criteria and it can be added from two locations: From either the
Fields tab or the Prompts tab.
Click the Prompts tab
The Prompts tab can be used to add runtime prompts and display a list of all prompts that
have been added to the query.
The Fields tab is the most common method of adding criteria and is useful when only adding
one runtime prompt.
Click the Fields tab
91
92
93
Note that a prompt has been added and is represented as a bind variable.
Click Save
Click Run
94
95
By using a prompt, the query is dynamic based on the Plan_Type chosen for each run.
96
To add a prompt for an additional field, such as coverage election, you would simply add
another row of criteria.
Click the Fields tab
Click the Add Criteria icon for the COVERAGE_ELECT field
97
Will display the bind variable or prompt name used for this criteria
Search Icon
New Prompt
Select this hyperlink to create a new prompt to be used for this row of criteria
Edit Prompt
Use this hyperlink to edit the existing prompt used for this row of criteria
99
100
You now have two prompts that will be used in your criteria.
Select Plan Type prompt: Long-Term Disability
Select Coverage Election prompt: Elect
Click OK
101
Results
102
Health_Benefit
Fields
Emplid
Plan_Type
Short description
Coverage_Begin_Dt
Coverage_Elect
Equal to E
Benefit_Plan
Order By
Emplid
Query Name
OX_GBLCO_MEDICAL
103
104
Results
105
Reminders:
You can add a prompt in two ways:
- Using the Prompts tab
- Using the Fields tab (most common method when adding one runtime prompt)
106
107
Edit Types:
- No Table edit
- Prompt Table
- Translate Table
- Yes/No Table
Unique Prompt Name is used in
translations No need to change this
field.
Click OK twice
108
Go to the Criteria tab: Note that a prompt has been added and is represented as a bind
variable.
Click Save
Click Run
109
A single prompt is displayed for you to select your specific criteria for the population you
want to retrieve
Select Medical
Click View OK
110
With the prompt, the query is dynamic based on the Plan_Type selected at run time.
111
To add a prompt for an additional field, such as coverage election, (which youve already
coded in the criteria), simply add another row of criteria.
112
113
114
Prompt Summary
Creating Prompts:
Prompts Tab
Criteria Tab
Useful when adding only one prompt to a query for a specified field
Editing Prompts once created, you can view them via one of the methods above
Prompts Tab
Criteria Tab
Deleting Prompts:
To delete a prompt, access the Prompts page and click the delete button
(minus sign) for the prompt you wish to delete. If you are using the prompt in a
row of criteria, you must remove it from the criteria before deleting it.
115
Writing Expressions
Record
Personal Data
Fields/Headings
Emplid
ID
Name
Employee Name
Sex
Gender(short desc)
Birthdate
116
118
119
120
Click on the Use as Field link to include this expression to your query results
121
122
Results
123
124
Click OK
Click on the Criteria tab
125
126
Results
127