Query Basics UNC
Query Basics UNC
2
Chapter 1
Technology Overview
PeopleSoft Query is an end-user reporting tool. You use queries to retrieve information from the database to a
web interface.
With PeopleSoft Query, you can extract the precise information that you’re looking for by using visual
representations of the PeopleSoft database and without writing Structured Query Language (SQL) statements.
Tables (records)
Tables are composed of columns and rows. In PeopleSoft databases, tables are built from record
definitions (or records for short). Record definitions are used by PeopleSoft Query to represent the
tables (example below).
3
How do I find out what tables I need to Query?
Control+J
Columns (fields)
Columns store single pieces of information for each row (example above). Course ID: (COURSE_ID)
is a column in the CRSE_CATALOG_TBL table.
For example, in the CRSE_CATALOG_TBL table a row includes the data for these fields:
COURSE_ID, EFFDT, EFF_STATUS, DESCR, and DESCRLONG
Keys
Keys are one or more columns on a table that make each row unique.
The key fields for the CRSE_CATALOG_TBL are Course ID and Effective Date (COURSE_ID and
EFFDT)
4
Why should I use PeopleSoft Query?
Query Manager
Query Manager uses these methods to obtain information from the database:
Term Definition
Aggregate Performs a computation on a set of values rather
than on a single value. (add, average, etc)
Criteria Refines the query by specifying conditions that the
retrieved data must meet.
Data Row Contains the values for each field in a table.
5
Distinct Removes duplicate rows of data.
Effective Date Dates information in the system giving the capability
to have future, current and historical data stored in
the database and ready to retrieve with the
appropriate security.
This diagram illustrates how PeopleSoft Query accesses PeopleSoft databases and how queries
are exported to other file types:
In a PeopleSoft Database:
6
Commonly used Tables in Campus Solutions
CLASS_TBL
1. COURSE_ID
2. CRSE_OFFER_NBR
3. STRM - Term
4. SESSION_CODE
5. CLASS_SECTION
FACILITY_TBL
1. SETID
2. FACILITY_ID
3. EFFDT
CLASS_INSTR
RQ_GRP_TBL
CLASS_ASSOC
CLASS_ATTRIBUTE
CLASS_NOTES_TBL
CLASS_FEE_TBL
CLASS_MTG_PAT
SCTN_CMBND
o ACAD_PROG
1. A student’s effective dated Program Statuses (Active, Discontinued,
Dismissed, etc.).
2. A student’s Academic Program.
3. Program Action Reason that describes the corresponding action.
4. A student’s Expected Graduation Term.
5. A student’s Degree Checkout Status.
6. A student’s Admit Term.
7
1. A student’s subplan (specialization in their major).
o STDNT_ENRL
1. Historical Student Enrollment (by term). The table that holds the detail of all
courses/grades taken in residence.
o STDNT_CAR_TERM
1. A student’s cumulative units and term units.
2. A student’s cumulative GPA.
3. A student’s academic level (freshmen, sophomore, junior, senior, graduate,
postbac).
4. A student’s academic load (full time, part time) for a term.
5. A student’s primary academic program (for a term).
6. A student’s eligible to enroll flag (for a term).
o ACAD_DEGR
1. Student Degrees earned at this institution.
o ACAD_DEGR_PLAN
1. The plan(s) in which the student has earned a degree at this institution
o CLASS_TBL
1. Schedule of Classes
o CRSE_CATALOG
1. Course data like DESCRIPTION, UNIT VALUES, GRADING BASIS
o CRSE_OFFER
1. Course data like SUBJECT, CATALOG NBR, REQUIREMENT GROUP
o STDNT_GRPS_HIST
1. All Student Group(s) that the student is (was) active in or inactive in.
o ACAD_STDNG_ACTN
1. The student’s end of term academic standing.
8
o SRVC_IND_DATA
1. The student’s current Service Indicators (holds).
o STDNT_ENLR_APPT
1. The student’s enrollment appointment (assigned per term/session).
o STDNT_TEST_COMP
1. All student test scores.
Transfer Credit:
TRNS_CRSE_DTL
STDNT_CAR_TERM
TRNS_TEST_DETAIL
Financial Aid:
ISIR_00_3_EC - ISIR 3 EC
9
ISIR_COMMT_TBL - ISIR Comment Descriptions
Student Financials:
ITEM_SF
ITEM_LINE
SF_ACCTG_LINE
10
TUIT_CALC_TBL
BILL_HEADER
ITEM_TYPE_TBL
REFUND_HDR
REFUND_DTL
BILL_HEADER_VW
COLLECTION_SF
11
Chapter 2
Using the Query Manager
12
How do I Search and Manage Queries?
Navigation:
Reporting Tools
Query
Query Manager – Click the Search button
13
Features of Query manager Search Page
Feature Usage
Search by: Perform a quick search using any field in the drop-down list box.
Advanced Search Select this link to narrow a query search using eight search categories and other
conditional criteria.
Folder View Displays queries by folder name.
Action Organize, copy, delete, and rename queries.
Select Select this check box to flag a query for an action.
Check All and Uncheck All Click these buttons to select or deselect all queries that are in the search list.
HTML Select this link to run a query to HTML format.
Excel Select this link to run to Excel
Schedule Select this link to access the Process Scheduler Request page and set the particular
date and time to run the query.
Security Permissions
If the Query Manager link does not appear under the Query folder, the security administrator must grant
access to the Query Manager component (QUERY_MANAGER) and pages.
14
Query Manager Advanced Search
You can narrow the focus of a search by using the Query Manager advanced search. This page enables you
to search using:
15
Advanced Search
Field Description
Query Name Enter the name of the query.
Description Enter a description of partial description of the query.
Uses Record Name Enter the record with which the query is associated.
Note: The record might be used by multiple queries, so you might get more results than you
plan.
Uses Field Name Enter a field that the query uses.
Note: The field might be used by multiple queries, so you might get more results than you plan.
Access Group Name Enter the access group with which the query is associated.
Folder Name Enter the name of the folder that stores the query.
Query Type Enter the query types: role, user, process, or archive.
Owner Enter whether the query is public or private.
16
Conditional Logic Operators
Organizing Queries
Once you locate the desired queries, you use the Actions options to help you organize the selected queries.
17
Options in the Action Field – Step 3 from the Action dropdown list box:
Action Purpose
Add to Favorites Adds queries to the My Favorite Queries list.
Copy to User Copies private queries to other users.
Note: The user that you copy to must have access to the records with which the query is associated
Delete Selected Deletes the selected queries from the database.
Move to Folder Moves queries to folders.
Rename Selected Changes the name of the selected queries.
My Favorite Queries
You can quickly access a frequently used query from the Query Manager search page by designating the
query as a favorite. After you create a favorite, the favorites appear on the search page automatically.
Click the triangular arrow next to the My Favorite Queries label to expand and collapse the list.
Note: Queries in the My Favorite Queries list are linked to the user ID.
1. Click the Remove button (the minus button) to remove one query from the list.
2. Click the Clear Favorites List button to remove all queries from the list.
18
Creating and Using Folders
Use folders to organize queries. Create a folder structure that suits the needs of users.
19
Query Manager
This diagram illustrates the menu navigation and pages of Query Manager:
20
Query Manager:
Is browser-based.
Is organized to facilitate ease of use.
Enables you to create queries that retrieve data without having to know Structured Query Language
(SQL).
The pages of Query Manager enable you to tailor queries to retrieve data that is specific to the business needs
of users.
This table lists the name and purpose of each of the Query Manager pages:
You must select at least one record before you can create
and save a query.
Query Select the fields that you need for the query.
You must select at least one record before you can create
and save a query.
Expressions Create formulas to use with the query.
Prompts Create runtime prompts.
Fields View, edit, sort, and reorder fields that appear in a query.
Criteria Filter data to retrieve only those rows that you need to see.
Having Create criteria for fields that use aggregate functions.
View SQL View the SQL that is generated when the query is created.
Run View the results of the query.
21
Steps Used to Edit Fields in an Existing Query
22
Pages Used to Edit Fields in an Existing Query
23
Using the Fields Page
Button Usage
Reorder / Sort Click this button to determine:
Field-by-field the sort order and direction of the query results.
The order that the columns will appear in the query results.
Add Criteria Click this button to determine any conditional criteria for the selected field.
Edit Click the Edit button to display the properties of the individual field.
Delete (minus sign) Click this button to delete the associated field from the query.
Note: The fields that you select on the Records page determine the fields that appear on the Fields page. Expressions that you use as fields also
appear on this page.
After selecting the Edit button on the specific field you wish to change the following page will display. Use this
page to edit your field properties.
24
___________________________________________________________________
ACTIVITY 1 – Using Query Manger
(Approximately 20 min)
Activity overview:
Creating a Folder:
1. From the Action dropdown list select Move to Folder (make sure you have your query selected first
by placing a check in the checkbox).
2. Click the Go button.
3. On the move to Folder page, select the second radio button, and enter your ONYEN in the blank
field.
4. Click the OK button.
25
Editing a Query:
1. On the Search page search for your query again.
2. Click the Edit link of the XXX_TRAINING_SESSION query in the My Favorite Queries list.
3. Select the Run tab from Query Manager to view the query results.
4. Select the Fields tab to edit the column headings.
5. Click the Edit button of the SESSION_CODE field.
6. Select the Text option from the Edit Field Properties page.
7. Enter Course Session for the Heading Text, and click the OK button.
8. Click the Delete button for the HOLIDAY_SCHEDULE field.
9. Save the query.
10. Select the Run tab to view the results of the XXX_TRAINING_SESSION query.
26
Chapter 3
Creating a Simple Query
Methods to Create a Query
Click the Create new Query link on the Query Manager search page.
Click the new Query link at the bottom of the pages that are in Query Manger.
27
Selecting Query Output and Editing Query Properties
Records Page
The first step in creating a query is selecting a record in the Records page. The record that you select
establishes the primary focus of the query.
This diagram shows how to access the Records page of the Query Manager Component:
Navigation:
28
Use this page to search for and select records:
The Records page appears after you click the Create New Query or the New Query link.
The Records search page provides basic and advanced search options.
You have to click the Search button to display a list of records based on the search criteria that you
enter.
You must select at least one record and at least one field to create a query.
29
Links and Buttons on the Records Search Page
This table explains the links and buttons on the Record basic and advanced search page:
30
Query Page
After you select a record, the Query page appears and enables you to select the fields used in the query.
This diagram shows how to access the Query page of the Query Manager component:
31
Navigation:
32
Effective-Dated Tables
If you select a record that contains the EFFDT field, PeopleSoft Query automatically add effective date criteria
to the query and displays a message as in the example:
This table describes the fields and buttons on the Query page:
33
The Fields Page
Navigation:
34
Use this page to edit field properties and to determine column and sort order.
This table describes the fields and buttons on the Fields page:
35
Order By Feature
The Order By feature places a number next to the field indicating which field is:
Note: Descending sort means sorting from Z to A. Ascending sort means sorting from A to Z.
The Query Properties page enables you to enter or view additional information regarding the query, such as:
36
________________________________________________________________________________
Note: The first time that you save a new query, the Query Properties page appears to enable you to document the query. Be aware, however, that you
cannot save queries by using the Query Properties page.
Navigation:
37
Fields on the Query Properties Page
This table explains the fields that are on the Query Properties page:
Field Usage
Query Enter a query name. Query names are uppercase and can be up to 30 characters.
Only the user who creates the query can open, run, modify, delete the query or change the
owner to Public.
Public: Any user with access to all records used for the query can run the query. Public
security access is needed open, run, modify or delete the query.
Only the user who creates the query can open, run, modify, delete private queries, or
change security access. Any user with access to all records in the query can perform any
operation on a public query if that user has rights to create a public query.
Distinct Select to remove duplicate rows of data in a query.
Query Definition (Optional) Enter text to further describe the query definition.
38
Editing Field Properties Page
This diagram shows how to access the Edit Field Properties page:
Navigation:
39
Use this page to change field column heading and to apply an aggregate function to this field:
1. On the Fields page, click the Edit button associated with the field.
2. Select any one of the options in the Headings group box, or enter text to change the field heading.
40
Fields with Translate Values
When you edit a field that has translate values, the Edit Field properties page displays translate value options.
You can select whether the output displays the short or long translate value.
Translate tables are effective-dated, so you must select which effective date to use for them. For most tables,
PeopleSoft Query defaults to the current date, meaning that it uses the currently active list of Translate table
values.
1. Select the Fields page, and then click the Edit button for the field.
2. Select an option from the Translate value group box of the Edit Field Properties page.
3. Click the OK button.
41
Removing Duplicate Rows of Data
This diagram shows the process flow to remove duplicate rows of data from a query:
Distinct Feature
Sometimes query results display the same row of data more than once.
If you enable the Distinct feature on the Query Properties page, the system removes duplicate rows of data in
the results.
42
_____________________________________________________________________
ACTIVITY 2 – Create a Query, Remove Duplicate Rows and Edit
(Approximately 15 min)
Activity overview:
Create a query
1. If necessary, sign in to the database.
2. Access Query Manager.
3. Create a new query using the RESIDENCY_SELF record.
4. Select the following fields from the record COUNTRY and POSTAL and STATE.
5. Save the query as your XXX_DISTINCT, (XXX is your initials) and view the query results.
6. Answer the following question:
a. How many rows of data were returned? ___________
Editing a Query
1. Click the Query page and select and COUNTY in addition to the other fields.
2. Select the Fields page.
3. Click the appropriate Edit buttons and make the following changes:
Field Heading
COUNTY Select text radio button
Change to Preferred County
43
Chapter 4
Filtering Output with Criteria
Often you do not want to retrieve every row of data from the record that you are accessing. Criteria serve as a
condition that the system applies to each row of data in the tables that you are querying. If the row meets the
condition, the system retrieves it; if the row does not meet the condition, the system does not retrieve it. By
defining criteria rows in the query, you:
44
Editing Criteria Properties Page
This diagram shows the pages that you can use to access the Edit Criteria Properties page:
Click the Use as Criteria button (filter icon ) on the Query page.
Click the Add Criteria button (filter icon ) on the Fields page.
45
Add Criteria Button
The Add Criteria button appears as a filter icon or as a push button depending on the page that you use.
When you click the Add Criteria button from any page other than the Criteria page:
You automatically add the associated field to the Edit Criteria Properties page.
The Edit Criteria Properties page appears, enabling you to complete the criteria as necessary.
46
Use this page to work with expressions and add criteria to queries:
47
Query criteria are like an equation. As with an equation, query criteria consist of a left side, an operator, and a
right side.
This diagram shows the comparison between equations and query criteria:
48
Use this page to define the criteria:
This table explains each element of the Edit Criteria properties page:
Element Purpose
Choose Expression 1 Type Determines whether the first part of the selection criteria is based on a field or an
expression.
Expression 1 Contains the value of the first part of the selection criteria.
Condition Type Determines how Query Manager compares the first expression value to the second
expression value.
Choose Expression 2 Type Determines whether the second part of the selection criteria is based on a field, an
expression, a constant, a prompt, a subquery, etc.
Expression 2 Contains the value of the second part of the selection criteria.
To use a field as criteria in expression 1, click the lookup button to select one field from the list of fields in the
record:
49
Using Expressions as Criteria in Expression 1
To use an expression as criteria in expression 1, use one of the links or the lookup button to search for or edit
an existing expression, or create a new expression.
This diagram shows the process flow that you use to add criteria:
50
Using the Edit Criteria properties Page
When you use the Criteria Properties page, you should note that:
Clicking Add Criteria button – whether from the Query page, the Fields page, or the Expression page –
automatically inserts the associated field or expression in the Expression 1 section of the Edit Criteria
Properties page.
The Choose Expression 2 Type field varies depending on the option that you select in the Condition
Type field.
The Expression 2 field varies depending on the option that you select in the Choose Expression Type 2
field.
51
Criteria Page
This diagram shows how to access the Criteria page of Query Manager:
52
Use this page to add and edit criteria or to view the new row of criteria after you create it from the Edit Criteria
Properties page:
You can add criteria directly on the Criteria page, but the user must then take the extra step of selecting the
field for expression 1, which might be a considerable task on larger records.
Element Use
Add Criteria Inserts a row of criteria into the query.
Note: Query Manager enables you to use one or multiple rows of criteria in a single query.
Group Criteria Enables you to apply multiple selection criteria as one criterion.
Reorder Criteria Enables you to reorder criteria rows without deleting the existing criteria.
Logical operator list Enables you to select the Boolean operators AND, AND NOT, OR and OR NOT.
Edit Modifies the existing row of criteria.
Delete (minus sign) Deletes the row of selected criteria.
53
Refining Criteria
Condition Types
The more you use Query Manager, the more you are likely to refine queries with conditions other than the
equal to condition.
Query Manager provides 18 conditions that you can apply to the criteria.
Each condition type correlates to certain expression 2 types.
This table lists the condition types and their correlation to expression 2 types:
54
Results from the Commonly Used Conditions
This table shows the results of these commonly used conditions:
55
Expression 2 Type
Use these guidelines to choose the appropriate expression 2 type, and specify the expression to which expression 1 type
compares:
If you select Expression as the type, the Add Prompt or Add Field links appear for you to select an expression for
expression 2:
56
If you select Constant as the type, the Constant field appears for you to enter the expression or constant for expression 2:
If you select Prompt as the type, the lookup button, and the New Prompt and Edit Prompt links appear for you
to define the expression or prompt for expression 2:
If you select Subquery as the type, the Define/Edit Subquery link appears for you to enter the expression or
Subquery for expression 2:
57
Equal to Condition
The equal to condition finds rows of data with values that match the constant that you specify in expression 2.
This diagram shows the expression 2 types available when you select the equal to condition type:
You can apply the condition equal to for retrieving students who are in the U.S. and by information in their
program of study.
Like Condition
The like condition retrieves data that matches a portion of a character string.
This diagram shows the expression 2 types when you select the like condition type:
58
Constant Expressions used with the Like Condition
Any constant expression that you use with the like condition is case-sensitive. You can use wildcard
characters to assist in the search for data. This table describes the use of wildcard characters:
Examples
This table gives examples of the result set when you use the like condition with wildcard characters:
Identifying Mistakes
Minor mistakes with wildcards can return radically different results, especially when using the like condition.
Some common mistakes are:
59
Is Null Condition
You use the is null condition to search for fields that have no value.
The fields that PeopleSoft supports for the is null condition type are:
Long character
Image
Date
Time
Datetime fields
If you select the is null condition, expression 2 disappears because is null defines the criteria for the second
expression.
60
Between Condition
Use the between condition to filter data based on a range of two values that you specify in expression 2.
Suppose you need to retrieve students whose session begins date is between May 1, 2008 and May 30, 2008.
61
Results when you apply the between condition:
62
In List Condition
Use the in list condition to limit data retrieval to a predefined set of values.
This diagram shows the expression 2 types when you select the between condition type:
63
Adding Comparison Values to the List
1. On the Edit Criteria Properties page, click the lookup button in the Edit list group box.
a. The Edit List page appears
2. Enter data in the value field.
3. Click the Add Value button.
4. Click the OK button.
64
In Tree Condition
Trees depict hierarchical structures that represent a group of summarization rules for a particular database
field.
The in tree condition provides access to PeopleSoft Tree Manager to retrieve hierarchical data for the query.
This illustration shows the expression 2 types when you select the in tree condition type:
Think of a tree as a visual representation of a set of summarization rules for a database field. The tree
specifies how the system groups the values of the field for purposes of reporting or security access.
A tree can specify how to summarize or roll up Academic Organizations for reporting purposes.
Using trees, you can access information in ways that match the groupings and hierarchies that already exist in
the organization.
65
The tree in the following example is called the ACAD_ORGANIZATION tree. This tree is built on the
ACAD_ORG field and shows the subject rolls up to a particular academic organization that rolls up to the main
business unit of the University.
Query Manager provides the in tree condition to access hierarchical summarized data from PeopleSoft Tree
Manager.
You can take advantage of the in tree criteria in that when you select nodes, all nodes beneath the selected
nodes are automatically included.
66
Example: Retrieving Data Using the In Tree Condition
1. Use the ACAD_ORG field for expression 1 to retrieve the information from the
ACAD_ORGANIZATION tree.
2. To access the ACAD_ORGANIZATION tree, click the New Node List in the Expression 2 group box on
the Edit Criteria Properties page.
3. Click the Search button to display all trees on the tree list, as shown:
67
4. Select the appropriate tree for the query.
In this case, use the ACAD_ORGANIZATION tree.
5. Click the Add to node Selection list icon as shown below and then click the OK button.
The Edit Criteria Properties page displays the DEN which is for the School of Dental Medicine.
68
69
6. Select the Criteria page to view the in tree condition that you added:
7. Select the Run page to view the results with rows of data showing the subjects from the academic
organization of the Dental School.
70
71
Using the In Tree and In List Conditions
The in tree condition works almost like the in list condition. The differences between using the in tree and in
list condition are:
When using the in tree condition, if you add field values to a tree node (for example, you add another
subject to the School of Medicine), the values are automatically brought in at runtime.
When using the in list condition, if you decide to add field values (for example, a new instructor or
manager starts in the School of Medicine), you must update all the queries with the value.
This diagram shows the steps used to refine criteria and retrieve query results:
72
Using Multiple Criteria Statements
Boolean Expressions
There are four types of Boolean expressions available on the Criteria page.
AND
AND NOT
OR
OR NOT
If you add multiple lines of criteria to a query, you must use Boolean operators to specify the way that the
system applies each criterion.
Boolean Operators
This is a list of Boolean operators and example of how you interpret each operator:
AND: Returns only rows that meet the conditions of all criteria.
Use the AND operator to view only international students with a capital D in their names.
AND NOT: Returns only rows that meet the condition that precedes this operator but yet do not meet
the condition that follows this operator.
Use AND NOT operator to view only international students except for those who have a capital
D in their names.
OR NOT: Returns rows that meet the condition that precedes this operator and rows that do not meet
the condition that follows this operator.
Use the OR NOT operator if you want to return all international students and students whose
name does not have a capital D regardless of their citizenship status.
Note: The AND NOT and the OR NOT operators are likely to force table scans instead of index reads to pull data. When needed you should use NOT
IN or <> for better performance.
73
Example: using Boolean Logic in Criteria
Suppose you want to view all courses that have all of the following conditions:
Criteria:
The session beginning date is in 08/25/2008.
The term is 2088
The career is NOND
1. Run the query with no criteria and selecting the following fields.
74
As you become proficient in adding multiple rows of criteria, you may need to reorder the rows of criteria to
achieve the wanted results.
The Reorder Criteria button on the Criteria page provides the ability to reorder rows of criteria without deleting
and re-entering existing criteria.
75
76
Grouping Criteria
When you have more than one criteria row, you can use the group Criteria feature to control the order in which
Query Manager applies the criteria row.
You enclose the criteria within parentheses to force the system to evaluate those criteria first.
77
Process to Create Multiple Rows of Criteria
This diagram shows the process you use to create multiple rows of criteria:
78
Effective Date
PeopleSoft applications use the effective date field (EFFDT) to enable you to view data that changes over time.
This diagram shows how the system classifies data into categories based on the effective date:
Category Description
Current The Current row of data is defined by closest to without exceeding the current days date. There
can only be on current row per high-level key to a table.
History The effective date is less than the effective date of the current row.
Future The effective date is greater than today’s date (system date on the server).
79
Effective-Dated Record
When you start a new query and select an effective-dated record, a new effective-dated criteria row is created, and an
informational message appears on the screen:
If you choose an effective-date condition (visible on the Criteria page in the Conditions Type column), you
return one effective-dated row of information per item. You can vary what you want the effective date
compared against.
This table describes the effective-date conditions on the Edit Criteria Properties page:
Effective-Date Condition Description
Effective Date <= Maximum Effdt {<=,<} {current date, constant, field}
Effective Date <
Effective Date >= Minimum Effdt {>=,>} {current date, constant, field}
Effective Date >
First Effective Date Return the row with the oldest effective date, the first row that is entered for an item.
Last Effective Date Return the row with the latest effective date, even if that date is still in the future.
Often, effective-dated tables have an effective status field. The effective status (EFF_STATUS – has two field
associated with it as translate values Active and Inactive). If you are working with effective-dated tables and
looking for the current row of information, you may also want to add criteria in the EFF_STATUS field to specify
only active rows. The table may also include the effective sequence field (EFF_SEQ) used when multiple
transactions occur on the same effective date.
80
_____________________________________________________________________
ACTIVITY 3 – Creating, Editing and Refining Queries with Effective-Dates and
Complex Criteria
(Approximately 25 min)
Activity overview:
Create a query:
1. If necessary, sign in to the database.
2. Access Query Manager, and create a new query using the ITEM_TYPE_TBL.
3. It will indicate to you the table is effective dated, you will accept the criteria and click OK.
4. Select the following fields:
81
Results
18. Add a third criteria row, and enter the following information:
83
Applying Boolean Logic
1. Select the OR option in the Logical dropdown list box for the field of TAXABLE_Y_N
84
3. Move your newly created query to the folder you created in the previous exercise.
Reorder Criteria
1. Click the Reorder button and reorder your criteria as indicated in the following screen shot.
85
Grouping Criteria
1. You will be utilizing the same query you just created.
2. On the Criteria page click the Group Criteria button.
3. Enter open parentheses in the left text box of row 1 (EFFDT field).
4. Enter close parenthesis in the right text box of row 3 (ITEM_TYPE,).
86
5. Click the OK button.
6. Save the query.
7. Run and view the query.
Results
87
Chapter 5
Filtering Output with Runtime Prompts
Describing Runtime Prompts
Prompts extend the life of a query and make the query more flexible for future requests.
This diagram shows the process flow for using runtime prompts:
The query becomes more flexibly because you do not have to create multiple queries with hard-coded values
for each specific parameter in which to search on.
88
Prompt Table Edit
This type of edit restricts selection to only data that is in the prompt table.
89
Translate Table Edit
This type of edit restricts selection to only data that is in the Translate Table (PSXLATITEM). THE Translate
table is a PeopleTools table predefined values that are associated with a particular field.
This type of edit restricts you to selecting yes (Y) or no (N) values.
Runtime Prompt
This diagram shows the pages that you can use to access the Edit Prompt Properties page and to add runtime prompts:
There are two locations in which you can access to create runtime prompts:
Prompts page
Criteria page
90
Creating Prompts from the Prompts page
Use the following page to create and save multiple prompts that you can use later as selection criteria:
91
Expression 2 – Define prompt Group Box
4. In the Choose Expression 2 Type select the radio button for Prompt.
5. In the Expression 2 group box select the New Prompt link.
92
6. The Edit Prompt Properties for the record.field you selected appears and all properties are filled in for
you.
7. Click the OK button.
8. Click the OK button again to bring you back to the Criteria tab.
9. Click the Run tab to see the prompt and test.
10. Save if you like the results if not you may go back and adjust your prompt or criteria.
The steps to add multiple prompts are the same steps that you use to add a single prompt; you need only to
additional rows of criteria, and then select an Expression 2 type of prompt each time.
93
_____________________________________________________________________
ACTIVITY 4 – Creating Runtime Prompts and Date Range Prompts
(Approximately 15 min)
Activity overview:
Create a query
Add criteria
Add a runtime prompt
Create a prompt for a date range
Creating a query
1. If necessary sign in to the database.
2. Access the Query Manager, and create a new query using the ADJ_TERM_TBL record.
3. Enter the following information:
Field Heading
ADJUST_REASON Selected
Choose text and type in – Adjustment Reason
SESSION_CODE Selected
FROM_DAY Selected
TO_DAY Selected
REFUND_PCT Selected
Choose Long name
94
Results
95
Adding Runtime Prompts
1. Using the same query you just created, select the criteria page, and then click the Add Criteria
button
2. Enter the following information:
3. Click the New Prompt link, and enter the following information:
Testing:
Test 1 – Click the Run tab and type in SNS in the new prompt that appears in the upper left corner.
Test 2 – Click the Rerun query link and leave the field blank this time.
1. Click the Add Criteria button, and enter the following information:
3. Click the Add Criteria button, and enter the following information:
96
Expression 1 Type Field
Expression 1 CURRENCY_CD
Condition Type Equal to
Expression 2 Type Prompt
Expression 2 Click the New Prompt link
Examine the properties and click ok to return
4. Click OK again to return to the Criteria page, and save the query.
5. Run the query and examine the results.
97
Chapter 6
Working with Multiple Tables
Describing the Purpose of Joins
When you join two records (tables), you relate them to each other.
Purpose Example
Retrieve additional fields You join tables to retrieve a description (DESCR:
Community Dentistry) that explains a code (ACAD_ORG:
CMDN)
Limit the rows that are returned You join tables to retrieve only the student information
about students whose student IDs appear in the
Enrollments table.
It is very important to remember that you want to perform joins on a common key value present in the tables
you are joining together. Should you decide to join on other random fields you will create a Cartesian
join with unpredictable results.
Table View
Stores physical data Displays logical representation of data
Designed for data storage Designed for data retrieval
Organized for minimum redundancy Organized as necessary to meet business needs
Contains a specific type of related data Displays related data, but you define the
Typically with a naming convention of _TBL relationship
Typically with a naming convention of _VW
98
How do I find the tables I need for my Query?
Locating appropriate data sources is difficult if you are unfamiliar with the application. Use Query Manger to
access the PeopleTools tables PSPNLDEFN and PSPNLFIELD, and query these tables for the records and
fields associated with any PeopleSoft PIA page.
In the application from the page you are on you can press CTRL + J on a data entry page to view the page
name. Then use that name to complete the prompt that is in the query. Almost all definition names consist
only of uppercase letters.
The PSPNLFIELD table stores the page name and its associated fields.
B.FIELDNUM This field stores the tab order on the page. Order by this field
A.PNLNAME This field stores the page name that you viewed when you pressed CTRL + J.
Create a runtime prompt on this field to limit inordinate output.
A.DESCR This field stores a useful description of the technical page name (if
documented by the developer)
B.LBLTEXT This field stores the label that you see on the page
B.RECNAME This field stores the technical name of the record associated with the data.
B.FIELDNAME This field stores the technical name of the field
Example of CTRL + J
99
Record-Hierarchy Joins
Record-hierarchy join
Related-record join
Record-Hierarchy Joins
Record-hierarchy joins use records that are related through a parent-child relationship.
100
Click the Hierarchy Join link to see the page of applicable child table to create a join.
1. Select the Query page, and then click the Hierarchy join link.
2. Select the record to join from the list of parent-child records.
a. This record appears on the Query page and is assigned an alias letter in the order that you
added the records.
3. Select the necessary fields from the joined record.
101
Related-Record Join (smart join)
Related-record joins combine nonhierarchical records that share common fields. You determine this
relationship when you define a field’s prompt table relationships in the Application Designer.
Related records are specified to a field in the current record. If you use Application Designer to set field edit
properties so that the field validates against a prompt table, the related record link appears to the right of the
field.
Example:
102
Creating a Related-Record Join
1. Access the Query page, and then select the field that prompts against another table for its values.
a. The related record appears as a link to the right of the field.
2. Click the related record link that is associated with the field.
a. The new record appears on the Query page and displays an alias letter that shows the order of
joins.
3. Select the fields that you require from the joined record.
103
___________________________________________________________________
ACTIVITY 5 – Accessing Data in Multiple Tables Using Record-Hierarchy and
Related-Record Joins
(Approximately 15 min)
Activity overview:
Create a query
Add a record-hierarchy join
Add a related-record join
Create a query
1. If necessary sign in to the database.
2. Access Query Manager, and create a new query using the ACAD_DEGR record.
3. Select the following fields:
105
Chapter 7
Using Summary Calculations
For instance, instead of viewing all rows of data, you want to view only a count of rows; instead of
viewing the price of each item, you might want to see the average price of all items.
Having Criteria
When you associate a field with an aggregate, you cannot use that field in selection criteria. Structured
Query Language (SQL) supports the use of aggregate functions in the WHERE clauses, but PeopleSoft
applications don’t.
Because the Criteria page corresponds to a SQL statement’s WHERE clause, PeopleSoft Query
provides the Having page. This page enables you to add criteria on the aggregate instead of on the
field generating the aggregate. The Having page criteria appear in a SQL statement’s HAVING clause.
106
Using predefined Aggregate Functions
When you apply an aggregate function to a field, PeopleSoft Query replaces the field, wherever it
occurs, with the results of the function.
This table lists the aggregate functions in Query Manager and their uses:
107
Adding Aggregates
1. Select the Fields page, and then click the Edit button for the field to edit.
2. Select an aggregate function, and then click the OK button.
Note: You cannot use the Sum or the Average aggregate function with character fields.
108
Using the Having Criteria
Having Criteria
Note: You can add the criteria from the Fields page, and then the system populates Expression 1 of the Having criteria.
You do not have to access the Having page or the Edit Having Criteria Properties page. Those steps are optional.
If you create a row of Having criteria using the Edit Having Criteria Properties page, then:
1. Click the prompt button for Expression 1, select the appropriate field from the list, and click the OK
button.
2. Select the condition type.
3. Enter the value for Expression 2, and then click the OK button.
109
_____________________________________________________________________
ACTIVITY 6 – Using Having Criteria and Applying Criteria to Aggregated Fields
(Approximately 15 min)
Activity overview:
Create a query
Apply the Count aggregate function
Apply the Average aggregate function
Create a second query
Apply the Count aggregate function
Insert Having criteria
Creating a query
1. If necessary, sign in to the database.
2. Access Query Manager, and create a new query using the TUIT_CALC_TBL record.
3. Select the EMPLID, STRM and PRE_POST_AMT fields.
4. Save the query as XXX_COUNT (XXX is your INITIALS).
5. View the output, and answer this question.
a. How many rows of data are returned? ______________
Results
110
Applying the Count Function
1. Using the same query as you just created, select the Fields page and then click the Edit button for the
STRM field.
2. Select the Count option in the Aggregate group box, and then click the OK button.
3. Save the query.
4. View the output, and answer this question:
111
Applying the Max Aggregate Function
1. Using the same query, select the Fields page, and then click the Edit button for the PRE_POST_AMT
field.
2. Select the radio button for the Max aggregate function from the Aggregate group box, and then click the
OK button.
3. Save the query.
4. View the output, and answer this question:
Results
112
Adding a Row of Having Criteria
1. Select the Having page, and then click the Add Having Criteria button.
2. Enter the following information:
Results
113
114
Chapter 8
Query Viewer and Report Manager
Query Viewer
Query Viewer provides access to run and print queries, but does not enable you to create, delete, or edit
queries.
Query Viewer is a read-only version of Query Manager. Query Viewer enables security administrators to limit
some users to read-only access for all queries so that they can only view or print queries.
Query Viewer retrieves all of the queries to which you have access but for which you have not editing or
creating capabilities.
Note: if you cannot access Query Manager, you can still view queries through Query Viewer.
115
Steps to View a Query Using Query Viewer
116
Scheduling a Query
You use the Schedule a Query component to run queries at specified times.
117
Report Manager
Separate Handout
Congratulations!!
You have completed Query Basics
118