Albertsons PSQuery Advanced
Albertsons PSQuery Advanced
Albertsons PSQuery Advanced
1
Agenda
Creating Expressions
– Build Expressions
– Add Expressions to Query
– Add Expressions in Criteria
– Add Prompt in Expressions
Using Subqueries
– Explaining Subqueries
– Creating a Subquery
– Edit a Subquery
Joining Records
– Describing Joins
– Creating Left Outer Joins
2
Creating Expressions - Build Expressions
3
Creating Expressions - Build Expressions
• Navigate to : Reporting
Tools Query Query
Manager
4
Creating Expressions - Build Expressions
5
Creating Expressions - Build Expressions
The first step in creating a query is to find an existing record for the query. In this example , you want to locate and use the
ADDL_PAY_RECORD
6
Creating Expressions - Build Expressions
7
Creating Expressions - Build Expressions
8
Creating Expressions - Build Expressions
9
Creating Expressions - Build Expressions
10
Creating Expressions - Build Expressions
11
Creating Expressions - Build Expressions
12
Creating Expressions - Build Expressions
13
Creating Expressions - Build Expressions
14
Creating Expressions - Build Expressions
15
Creating Expressions - Build Expressions
Use the Edit Expression Properties page to select expression type, length, decimals(for Number and Signed Number) and to
enter expression text
16
Creating Expressions – Add Expression to Query
17
Creating Expressions – Add Expression to Query
An expression can be treated just as a field in the query: select it for output, change its column heading, or choose it as an “order by”
column.
• In this example, you
will change the
heading to text of the
expression field
18
Creating Expressions – Add Expression to Query
19
Creating Expressions – Add Expression to Query
20
Creating Expressions – Add Expression to Query
21
Creating Expressions – Add Expression to Query
22
Creating Expressions – Add Expression to Query
23
Creating Expressions – Add Expression to Query
The results display the net and quarterly Other Pay amounts for each employee.
24
Creating Expressions – Add Expression to Criteria
25
Creating Expressions – Add Expression to Criteria
• Select Expression
A.OTH_PAY/4
26
Creating Expressions – Add Expression to Criteria
27
Creating Expressions – Add Expression to Criteria
28
Creating Expressions – Add Expression to Criteria
The results display the net and quarterly Other Pay amounts for each employee greater than 100.
29
Creating Expressions – Add Prompt in Expressions
30
Creating Expressions – Add Prompt in Expressions
31
Creating Expressions – Add Prompt in Expressions
• Select a Prompt
in this case :1
32
Creating Expressions – Add Prompt in Expressions
33
Creating Expressions – Add Prompt in Expressions
• Enter Number 4
34
Creating Expressions – Add Prompt in Expression
The results display the net and quarterly Other Pay amounts for each employee.
35
Using Subqueries - Explaining Subqueries
Subqueries
Let’s review first! Remember your algebra equations from school? The expression (x+1)y is
indicating that x+1 needs to be solved before multiplying the result by y. The equation inside the
parentheses needs to be executed, then applied to the operation outside the parentheses.
A subquery, sometimes called a sub-SELECT, is a query whose results are used by another query.
The main query uses the subquery’s result set as a comparison value for a selection criterion.
You create a subquery when you need to compare a field value to the results of a second query.
Suppose, for example, that you want a list of employees with active child support garnishments. For
each employee in the PERSONAL_DATA table, you must determine whether his or her employee ID is
in the GARN_SPEC table. That is, you must compare the value in the PERSONAL_DATA.EMPLID field
to the results of a subquery that selects the EMPLID values from the GARN_SPEC table.
36
Using Subqueries – Creating a Subquery
37
Using Subqueries – Creating a Subquery
38
Using Subqueries – Creating a Subquery
Different Condition Types explained
39
Using Subqueries – Creating a Subquery
40
Using Subqueries – Creating a Subquery
41
Using Subqueries – Creating a Subquery
42
Using Subqueries – Creating a Subquery
43
Using Subqueries – Creating a Subquery
44
Using Subqueries – Creating a Subquery
45
Using Subqueries – Creating a Subquery
46
Using Subqueries – Edit a Subquery
47
Using Subqueries – Edit a Subquery
48
Using Subqueries – Edit a Subquery
Navigate to Top Level of Query
49
Using Subqueries – Edit a Subquery
The results display employees with child support garnishments in Company 001.
You have successfully created a subquery using in list for company 001.
50
Summary Calculations - Aggregate Functions
The following table lists the aggregate functions that you can apply to a field using PeopleSoft Query.
51
Summary Calculations - Aggregate Functions
- Count explained
52
Summary Calculations - Aggregate Functions
- Sum explained
53
Summary Calculations - Aggregate Functions
- Sum explained
54
Summary Calculations - Aggregate Functions
The results display Location with no of employees and sum of hourly rate by Hr Status
You have successfully created a query using Aggregate functions Count and Sum.
55
Summary Calculations - Using the Having Criteria
PS Query/SQL does not support the use of aggregate functions in WHERE clauses. Therefore, after you have applied an
aggregate function to a field, you cannot use that field in your selection criteria, which corresponds to a SQL WHERE
clause. When you want to select rows based on the results of an aggregate function, Query Manager enables you to
create HAVING criteria. You might use such criteria, for example, when you want a list of location with more than 200
active employees.
56
Summary Calculations - Using the Having Criteria
57
Summary Calculations - Using the Having Criteria
58
Summary Calculations - Using the Having Criteria
59
Summary Calculations - Using the Having Criteria
The results display Location with no of employees greater than 200 and sum of hourly rate by Hr Status = Active
You have successfully created a query using the Having Criterai
60
Joining Records – Describing Joins
• Query Manager enables you to create queries that include multiple-table joins. Joins retrieve data from more than
one table, presenting the data as if it came from one table. PeopleSoft Query links the tables, based on common
columns, and links the rows on the two tables by common values in the shared columns.
• Joins are what make relational databases relational. Using joins, you define relationships among fields when you
query the records, not when you create the records. Because PeopleSoft records are highly normalized (they
each describe one kind of entity), you can easily use Query Manager to create joins.
• The procedure for joining tables differs depending on how the tables that are being joined are related to each
other. Query Manager recognizes three types of joins: record hierarchy, related record, and any record.
61
Joining Records – Describing Joins
62
Joining Records – Describing Joins
63
Joining Records – Describing Joins
64
Joining Records – Creating Left Outer Joins
• Left outer join forces a row from one of the participating tables to appear in the result if no matching row exists.
• PeopleSoft Query enables you to easily create a left outer join.In a left outer join, all rows of the first (left)
record are present in the result set, even if no matches are in the joining record.
This example you will use records Addresses and Phone to report Home Addresses and Home Phone
65
Joining Records – Creating Left Outer Joins
66
Joining Records – Creating Left Outer Joins
67
Joining Records – Creating Left Outer Joins
68
Joining Records – Creating Left Outer Joins
69
Joining Records – Creating Left Outer Joins
70
Joining Records – Creating Left Outer Joins
The results display Employee Home Address and Home Phone if exist.
You have successfully created a query using left outer join.
71
Query Administrative Tasks – Running a query from Query Viewer
• Navigate to : Reporting
Tools Query Query
Viewer
• Enter Query Name
LEFT_OUTER_JOIN
• Select Excel link
• Select Open
72
Query Administrative Tasks – Schedule Query
• Navigate to : Reporting
Tools Query Schedule
Query
• Enter Query Name
LEFT_OUTER_JOIN
• Enter Description Test
73
Working with Unions
UNION can also be a result set of results sets of two queries. ALL in the SELECT statement
includes duplicate rows. Column name comes from first table column name
Example:
Show me regular earnings for a paygroup.
74
Working with Unions
• Select records
PAY_EARNINGS and
PAY_OTH_EARNS
• Select fields COMPANY,
PAYGROUP, PAY_END_DT,
ERNCD, OTH_EARNS
75
Working with Unions
Results
Subquery/Union Navigation link used for toggling between Top Level of Query and Union1 records
76
Understanding Group By criteria
On some occasions , you will need to write a query that returns rows that meet some criteria, but not all of them. For example , you
may be asked to create a query to list Employees either hourly or with standard hours 20.
77
Demo
78
Questions
79