SQL Syntax & Distinct

This article provides information regarding the SQL syntax and the use of the DISTINCT criteria in PS Query.

Detailed information

Table of Contents

SQL

SQL View

  • PeopleSoft® Query will automatically generate SQL based on how you design your query.
  • When you go to the "View SQL" tab, you can see the SQL code.
  • You cannot modify the SQL from this page.

showing the location of the View SQL Tab in the Query Manager.

Back to top

Basics of SQL syntax

PeopleSoft® utilizes a subset of SQL standard functions. Simply, SQL is a set of instructions listing the SELECT on of specific fields, FROM specific tables WHERE certain circumstances exist.

  • SELECT: lists fields or column names used in the query
  • FROM: lists tables or records used in the query
  • WHERE: lists filters to include or exclude data

Showing an example of a Query SQL with SELECT, FROM, and WHERE highlighted with notes in the script.

Back to top

Distinct

When you wish to have a row of data appear only once—even though it may meet the criteria more than once—use the DISTINCT criteria. Distinct removes duplicate rows of output from the results.  

Example

Suppose you want a query that does not show every prospect, but you're interested in the last school attended for each career. 

Without Distinct

Career

Last School Attended

GRAD

 

GRAD

000000001

UGRD

000000001

UGRD

000000001

UGRD

000000001

UGRD

000000001

UGRD

000000001

UGRD

000000001

UGRD

 

GRAD

000000001

UGRD

000000001

UGRD

000010009

UGRD

000010005

UGRD

000010008

UGRD

000010009

 

*more*

With Distinct

Career

Last School Attended

GRAD

 

GRAD

000000001

MEDS

000000001

UGRD

 

UGRD

000000001

UGRD

000010005

UGRD

000010008

UGRD

000010009

Back to top

How to Set a query to Distinct Mode

To set a query to "distinct" mode, click the Properties link and check the Distinct check box. 

Showing the location of the Distinct checkbox in the Query Properties window.

Back to top

Environment

  • PeopleSoft Campus Solutions (CSPRD
  • PeopleSoft Campus Solutions Reporting (CSRPT)
  • PeopleSoft Human Resources (HRPRD)
  • PeopleSoft Financials (FNPRD)