Data Infrastructure IRAP Training 6/27/2016

Similar documents
Querying Data with Transact SQL

Querying Data with Transact-SQL

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 10g: Introduction to SQL

Querying Data with Transact-SQL

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Oracle Syllabus Course code-r10605 SQL

Oracle Database: SQL and PL/SQL Fundamentals NEW

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

CSC Web Programming. Introduction to SQL

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Querying Microsoft SQL Server 2014

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

5. Single-row function

Sql Server Syllabus. Overview

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

20461: Querying Microsoft SQL Server 2014 Databases

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

20461: Querying Microsoft SQL Server

COURSE OUTLINE MOC 20461: QUERYING MICROSOFT SQL SERVER 2014

CMPT 354: Database System I. Lecture 3. SQL Basics

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

20761 Querying Data with Transact SQL

8) A top-to-bottom relationship among the items in a database is established by a

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

Querying Data with Transact-SQL (20761)

Microsoft Querying Microsoft SQL Server 2014

Querying Data with Transact-SQL

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH

SQL Interview Questions

COURSE OUTLINE: Querying Microsoft SQL Server

After completing this course, participants will be able to:

MTA Database Administrator Fundamentals Course

Querying Microsoft SQL Server

Querying Microsoft SQL Server (MOC 20461C)

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Microsoft Querying Data with Transact-SQL - Performance Course

Computing for Medicine (C4M) Seminar 3: Databases. Michelle Craig Associate Professor, Teaching Stream

Querying Microsoft SQL Server 2012/2014

Structured Query Language (SQL)

AVANTUS TRAINING PTE LTD

Querying Microsoft SQL Server

SQL functions fit into two broad categories: Data definition language Data manipulation language

Relational Database Management Systems for Epidemiologists: SQL Part I

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

Querying Microsoft SQL Server

Querying Data with Transact-SQL

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

Unit Assessment Guide

20461D: Querying Microsoft SQL Server

ETL TESTING TRAINING

Course 20461C: Querying Microsoft SQL Server

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Querying Microsoft SQL Server 2014

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

Querying Data with Transact-SQL

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

Relational Database Languages

RESTRICTING AND SORTING DATA

Querying Microsoft SQL Server

Data Manipulation Language (DML)

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

Exam code: Exam name: Database Fundamentals. Version 16.0

MIS NETWORK ADMINISTRATOR PROGRAM

CGS 3066: Spring 2017 SQL Reference

COSC344 Database Theory and Applications. Lecture 6 SQL Data Manipulation Language (1)

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Information Systems Engineering. SQL Structured Query Language DML Data Manipulation (sub)language

Simple SQL Queries (2)

Querying Data with Transact-SQL

T-SQL Training: T-SQL for SQL Server for Developers

Querying Data with Transact-SQL

Review -Chapter 4. Review -Chapter 5

SAM Ad-Hoc. Gives direct, near unrestricted (view-only) access to your SAM database Ability to see raw data with queries created by you.

Full file at

Concepts of Database Management Eighth Edition. Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra

STIDistrict Query (Basic)

SQL - Data Query language

Querying Microsoft SQL Server

Slides by: Ms. Shree Jaswal

Intermediate SQL: Aggregated Data, Joins and Set Operators

1Z0-071 Exam Questions Demo Oracle. Exam Questions 1Z Oracle Database 12c SQL.

Relational Database Language

tablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one

1Z0-071 Exam Questions Demo Oracle. Exam Questions 1Z Oracle Database 12c SQL.

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key

SQL Workshop. Introduction Queries. Doug Shook

SQL Server 2012 Development Course

Transcription:

Data Infrastructure IRAP Training 6/27/2016

UCDW Database Models Integrity Constraints Training Database SQL Defined Types of SQL Languages SQL Basics Simple SELECT SELECT with Aliases SELECT with Conditions/Rules SELECT with Comparison Operators Not equal to, Equal to, Less than, Greater than, Less than or equal to, Greater than or equal to SELECT with Compound Conditions AND, OR, IN, NOT, BETWEEN, NOT BETWEEN, LIKE, NOT LIKE, EXISTS, NOT EXISTS Operators SELECT with Group By, Order By and Having Clauses SELECT with Concatenated Fields Joins Inner Join Left Join Right Join Full Join 2

UCDW Database Models Relational and Dimensional Models 3

Database Models Data Model Data Structure Integrity Constraints UCDW Database Models Relational Data Modeling Relational Structure UCDW Base Layer Dimensional Data Modeling Dimensional Structure UCDW BI (Business Intelligence) Layer 4

Data is stored in relational database system Several tables and chains of relationships between them Volatile Data is normalized Detailed level of transactional data Relational Data Modeling Data is stored in multidimensional databases Few facts are connected to dimension tables Non-volatile Data is de-normalized Summarized transactional data (aggregates and measures) used in business decisions Dimensional Data Modeling 5

Collection of tables and relationships Tables contain rows and columns or attributes Includes integrity constraints Includes domains set of possible values for a given attribute Relational Data Structure 6

Integrity Constraints Constraints in UCDW 7

Ensures That: Data conforms to guidelines specified by the Database Architect Data is consistent and correct Queries are optimized Performance is adequate Constraint Types Unique Primary Key Foreign Key Check Not Null 8

Used to enforce uniqueness of a column or a combination of columns that is no the primary key Ensures that all values in a column are different Uniquely identifies each record in a table Does not repeat Multiple unique key constraints can be applied per table Unique constraints allows NULL values Example SSN - unique constraint enforced in STUDENT_D dimension table 9

Uniquely identifies a record/row in a table Ensures all values in a column are different Automatically has a unique constraint Does not repeat Only one per table Could be natural or surrogate Could be composite (made up of more than one column/attribute) Primary key constraints do not allow NULL values Example - AWRD_KEY primary key constraint on the AWARD_D dimension table 10

Used to link two tables Refers to the primary key in another table Table containing a foreign key is called the child table Table containing the primary key is called the parent table Prevents actions that will violate relationship between tables Ensures that only valid data is inserted in child table Example ACAD_SUB_T_KEY, STUD_KEY, CRSE_KEY and CRSE_ENRL_STAT_KEY are all foreign keys in the COURSE_ENROLLMENT_F fact table. 11

Used to limit the values that can be placed in a column Allowable values are defined from a logical expression Defined on a single column means only certain values are allowed Defined on a table means values in certain columns must be based on values in other columns in the row Example STUD_IPEDS_GNDR_CD within STUDENT_D can only have values (F, M) 12

Requires that every row has a value for the NOT NULL column Enforces a field to always contain a value Example STUD_FST_NAM and STUD_LST_NAME cannot be NULL in the STUDENT_D dimension table 13

Training Database Subset of UCDW Dimensions and Facts for Training 14

ACADEMIC_SUB_TERM_D STUDENT_LEVEL_D ENROLLMENT_HEAD_COUNT_M ACAD_SUB_T_KEY STUD_LVL_KEY STUDENT_D ENROLLMENT_STATUS_D ACAD_SUB_T_KEY STUD_KEY STUD_LVL_KEY ENRL_STAT_KEY STUD_KEY ENRL_STAT_KEY 15

ACADEMIC_TERM_D DEGREE_AWARDED_F ACADEMIC_DEGREE_D ACAD_T_KEY CAMPUS_COLLEGE_MAJOR_D ACAD_T_KEY CMP_LOC_KEY ACAD_DGR_KEY CMP_CG_MAJ_CD_KEY STUDENT_D ACAD_DGR_KEY CAMPUS_LOCATION_D CMP_CG_MAJ_CD_KEY CMP_LOC_KEY STUD_KEY 16

STUDENT_D AWARD_D ACCOUNT_D STUD_KEY AWRD_KEY ACCT_KEY CAMPUS_LOCATION_D STUDENT_EARNINGS_F FILE_CYCLE_D CAMPUS_LOC_KEY FUND_D STUD_KEY AWARD_KEY CAMPUS_LOC_KEY FD_KEY ACCT_KEY FILE-CYCLE_KEY FILE_CYCLE_KEY FD_KEY 17

SQL Languages Types of SQL Languages 18

Standard for commands that define the different structures in a database Includes CREATE, ALTER and DROP commands Used by Data Architects and Database Administrators Data Definition Language (DDL) Standards for commands that manipulate data in a database Includes SELECT, INSERT, UPDATE, and DELETE Used by IT and Business Users to manipulate and extract data Data Manipulation Language (DML) 19

SQL Basics Basic SQL Statements 20

SQL Structured Query Language Create create a data structure * Select read one or more rows from a table Insert add one or more rows to a table * Delete remove one or more rows from a table * Update change the value of one or more fields in a row or within a table * Drop remove a data structure * 21

You are asking for the location, student ID, first name, last name, date of birth, gender and current active flag of students You want the data from the STUDENT_D dimension table SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D To get all columns from a table: SELECT * FROM STUD_BI.STUDENT_D 22

SELECT STUD_LOC_CMP_CD as Campus_Location, STUD_ID as Student_Identification_Number, STUD_FST_NAM as First_Name, STUD_LST_NAM as Last_Name, STUD_DT_OF_BTH as Date_of_Birth, STUD_GNDR_CD as Gender_Code, STUD_GNDR_DESC as Gender_Description, STUD_CUR_ACTV_FL as Current_Active_Flag FROM STUD_BI.STUDENT_D 23

You are asking for the location, student ID, first name, last name, date of birth, gender and current active flag of students You want the data from the STUDENT_D dimension table You have a condition the current active flag must be set to Y, SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = Y The WHERE clause evaluates to true or false 24

SELECT FROM WHERE AND AND AND STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD STUD_CUR_ACTV_FL STUD_BI.STUDENT_D STUD_CUR_ACTV_FL = 'Y' STUD_LOC_CMP_CD!= '01' STUD_GNDR_CD <> 'F' Comparison operators include: <> or!= Not Equal To = Equal to < Less than > Greater than <= or!> Less than or equal to (or not greater than) STUD_DMSTC_FGN_CZ_STAT_CD = 'F' >= or!< Greater than or equal to (or not less than) The AND operator joins two or more conditions. Returned rows must meet all conditions 25

You are asking for the location, student ID, first name, last name, date of birth, gender and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) whether student is domestic or foreign SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = Y AND STUD_LOC_CMP_CD = 01 AND STUD_DMSTC_FGN_CZ_STAT_CD = F 26

Logical Operators AND, OR, NOT, IN, BETWEEN, LIKE, EXISTS 27

SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CUR_ACTV_FL STUD_BI.STUDENT_D STUD_CUR_ACTV_FL = 'Y' STUD_LOC_CMP_CD IN ('01', '04') AND mandates that all specified conditions must be met! OR mandates that at least one condition must be met! FROM WHERE AND AND STUD_DMSTC_FGN_CZ_STAT_CD = 'F' AND ((STUD_GNDR_CD = 'M' OR STUD_IPEDS_GNDR_CD = 'M') OR (STUD_GNDR_IDNTY_CD = 'M' OR STUD_GNDR_AT_BTH_CD = 'M')) The OR operator joins two or more conditions but returns a row when ANY of the conditions are met. 28

SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CUR_ACTV_FL STUD_BI.STUDENT_D STUD_CUR_ACTV_FL = 'Y' Use NOT to negate selection criteria Sometimes it s easier to specify what you don t want by using the NOT operator FROM WHERE AND STUD_LOC_CMP_CD NOT IN ('01', '04', '06', '02', '07', '08') AND STUD_DMSTC_FGN_CZ_STAT_CD = 'F' AND ((STUD_GNDR_CD = 'M' OR STUD_IPEDS_GNDR_CD = 'M') OR (STUD_GNDR_IDNTY_CD = 'M' OR STUD_GNDR_AT_BTH_CD = 'M')) 29

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the citizenship status code has to one of a predefined set of values SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_CZ_STAT_CD IN ('US', 'PR', 'RF', 'AM', 'AP', 'AS', 'DA', ' ') 30

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the date of birth is not between January 8 th 1971 and January 8 th 1991 SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_DT_OF_BTH BETWEEN 01-08-1971 AND 01-08-1991 31

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the date of birth is between January 8 th 1971 and January 8 th 1991 SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_DT_OF_BTH NOT BETWEEN 01-08-1971 AND 01-08-1991 32

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the last name starts with the characters DELM SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_LST_NAM LIKE ( DELM% ) 33

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the last name starts with the characters DELM. The number of characters after the DELM is specified in this example. SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_LST_NAM LIKE ( DELM ) 34

You are asking for the location, student ID, first name, last name, date of birth, gender, citizenship status and current active flag of students You want the data from the STUDENT_D dimension table You have three conditions (1) the current active flag must be set to Y, (2) the location must be 01 Berkeley and (3) the last name does not start with the characters DELM SELECT STUD_LOC_CMP_CD, STUD_ID, STUD_FST_NAM, STUD_LST_NAM, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_LST_NAM NOT LIKE ( DELM% ) 35

SELECT CMP_LOC_LOC1_CD, CMP_LOC_LOC1_SHRT_DESC, CMP_LOC_LOC1_LNG_DESC, CMP_LOC_LOC1_MXD_CASE_LNG_DESC, CMP_LOC_LOC1_ABRV_DESC FROM STUD_BI.CAMPUS_LOCATION_D WHERE EXISTS ( SELECT STUD_LOC_CMP_CD FROM STUD_BI.STUDENT_D WHERE AND STUD_CUR_ACTV_FL = 'Y' STUD_LOC_CMP_CD IN ('01', 03', '05', '07', '09') AND STUD_BI.CAMPUS_LOCATION_D.CMP_LOC_LOC1_CD = STUD_BI.STUDENT_D.STUD_LOC_CMP_CD) ORDER BY CMP_LOC_LOC1_CD 36

SELECT FROM WHERE AND CMP_LOC_LOC1_CD, CMP_LOC_LOC1_SHRT_DESC, CMP_LOC_LOC1_LNG_DESC, CMP_LOC_LOC1_MXD_CASE_LNG_DESC, CMP_LOC_LOC1_ABRV_DESC STUD_BI.CAMPUS_LOCATION_D NOT EXISTS ( SELECT STUD_LOC_CMP_CD, FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD IN ('01', '03', '05', '07', '09') STUD_BI.CAMPUS_LOCATION_D.CMP_LOC_LOC1_CD = STUD_BI.STUDENT_D.STUD_LOC_CMP_CD) ORDER BY CMP_LOC_LOC1_CD 37

You are asking for the location, gender, citizenship status (domestic or foreign) and a count of students You want the data from the STUDENT_D dimension table You have one condition the current active flag must be set to Y Because you have a group/aggregate function (COUNT), you must include a GROUP BY clause to group the result-set SELECT STUD_LOC_CMP_CD, STUD_GNDR_DESC, STUD_DMSTC_FGN_CZ_STAT_CD, COUNT (DISTINCT STUD_ID) as Student_Count FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' GROUP BY STUD_LOC_CMP_CD, STUD_GNDR_DESC, STUD_DMSTC_FGN_CZ_STAT_CD 38

You are asking for the location, gender, citizenship status (domestic or foreign) and a count of students You want the data from the STUDENT_D dimension table You have one condition the current active flag must be set to Y You have a group by clause because of the aggregate function COUNT You have an order by clause to sort the results using campus location in descending order SELECT STUD_LOC_CMP_CD, STUD_GNDR_DESC, STUD_DMSTC_FGN_CZ_STAT_CD, COUNT (DISTINCT STUD_ID) as Student_Count FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' GROUP BY STUD_LOC_CMP_CD, STUD_GNDR_DESC, STUD_DMSTC_FGN_CZ_STAT_CD ORDER BY STUD_LOC_CMP_CD DESC 39

You are asking for a count of students by campus location. The DISTINCT keyword eliminates duplicates You want the data from the STUDENT_D dimension table You have one condition the current active flag must be set to Y You have a group by clause because of the aggregate function COUNT Because you have an aggregate function, you need a HAVING clause for your condition SELECT STUD_LOC_CMP_CD, COUNT (DISTINCT STUD_ID) as Student_Count FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' GROUP BY STUD_LOC_CMP_CD HAVING COUNT(DISTINCT STUD_ID) > 20000 ORDER BY STUD_LOC_CMP_CD ASC You have an ORDER BY clause to sort the results using campus location in ascending order 40

It may be necessary to concatenate campus location with student ID to join different content areas. For reporting purposes, you may also want to concatenate the last name with the first name to combine the fields into one SELECT STUD_LOC_CMP_CD STUD_ID as Student_Identification_Number, STUD_LST_NAM ',' ' ' STUD_FST_NAM as Student_Name, STUD_DT_OF_BTH, STUD_GNDR_CD, STUD_GNDR_DESC, STUD_CZ_STAT_CD, STUD_CUR_ACTV_FL FROM STUD_BI.STUDENT_D WHERE STUD_CUR_ACTV_FL = 'Y' AND STUD_LOC_CMP_CD = '01' AND STUD_DT_OF_BTH BETWEEN 01-08-1971 AND 01-08-1991 41

Simple Joins Joining Dimensions and Fact Tables 42

Left Join Right Join Inner Join Full Join 43

An inner join returns all records at the intersection of table A and table B A B 44

45

Joins Sub-Queries Views Inline View UNION, UNION ALL, INTERSECT, MINUS WITH CASE Statements DECODE Function Aggregate Functions Date Functions Character Functions 46