Go BackSQL: Advanced Query Techniques

Synopsis
SQL: Advanced Query Techniques describes how to compile SQL (IBM's Structured Query Language) queries to retrieve information from relational databases.

Audience
This course is designed for data processing and business professionals who want to use SQL to report on the information in their databases.

Time
4 - 7 hours

Product Code: SQL113
After completing this course, the student should be able to:
 
Select, parse and do arithmetic with date and time columns
Combine information from two tables via joining and merging techniques
Develop simple subqueries and subqueries that return several rows
Develop subselects involving nested table expressions

SQL Overview
Presents an overview of concepts pertaining to relational databases and SQL. Describes the tables used in the course.
 
Relational Concepts
Databases based on a relational model.  Components of relational tables.
Course Tables
Data found in the tables used in the course.
SQL Concepts
Purpose of SQL.  Features of Data Definition Language, Data Manipulation Language and Authorization Language.  Syntax rules for coding SQL statements.

Date and Time Functions
Describes how to use date and time data in SQL queries.
 
Selecting Date and Time Columns
Use of the DATE, TIME and TIMESTAMP data types.
Parsing Date and Time Columns
Use of the YEAR, MONTH, DAY, HOUR, MINUTE and SECOND functions.
Arithmetic with Date and Time Columns
Use of the YEARS, MONTHS and DAYS functions.

Combining Information from Two Tables
Describes the concepts and practices related to joining and merging tables.
 
Theory
Situations where you need to join or merge information from two tables.  Types of joins.
Inner Joins
Coding the FROM clause when joining two tables.  Specifying the joining condition.  Incorporating other search conditions.  How to order a query that joins two tables.  Use of built-in functions when joining tables.
Outer Joins
How to use and code the three types of outer joins.  Using the VALUE (COALESCE) function.
Merging
Coding UNION versus UNION ALL to merge tables.  Use of literals for columns with fixed values.  Considerations for the columns in tables to be merged.  Coding WHERE and ORDER BY clauses when merging tables.
Workshop
Building queries that join and merge tables.

Subselects
Describes the concepts and practices related to subqueries and subselects.
 
What is a Subselect?
Explanation of a subselect and a subquery.  Nested table expressions.
A Simple Subquery
Rules for coding subselects.  Coding the main SELECT versus the subselect. Valid relational operators when a single value is returned from the subselect.
Subqueries Returning Several Rows
Valid relational operators when more than one row is selected.  Coding IN, =ANY and =SOME for equality.  Coding ALL, ANY and SOME for greater or less than.
Workshop
Building queries that use subselects.


 

Go Back