Chapter 1 – Basic SQL Functions
SELECT * (All Columns) in a Table
Fully Qualifying a Database, Schema and Table
SELECT Specific Columns in a Table
Using the Best Form for Writing SQL
Place your Commas in front for better Debugging Capabilities
Sort the Data with the ORDER BY Keyword
ORDER BY Defaults to Ascending
Use the Name or the Number in your ORDER BY Statement
Two Examples of ORDER BY using Different Techniques
Changing the ORDER BY to Descending Order
NULL Values sort First in Ascending Mode (Default)
NULL Values sort Last in Descending Mode (DESC)
Multiple Sort Keys using Names vs. Numbers
Sorts are Alphabetical, NOT Logical
Using A CASE Statement to Sort Logically
A Missing Comma can by Mistake become an Alias
Using Limit to bring back a Sample
Comments using Double Dashes are Single Line Comments
Comments for Multi-Lines As Double Dashes Per Line
A Great Technique for Comments to Look for SQL Errors
The WHERE Clause limits Returning Rows
Using a Column ALIAS throughout the SQL
Double Quoted Aliases are for Reserved Words and Spaces
Character Data needs Single Quotes in the WHERE Clause
Character Data needs Single Quotes, but Numbers Don't
NULL means UNKNOWN DATA so Equal (=) won't Work
Use IS NULL or IS NOT NULL when dealing with NULLs
NULL is UNKNOWN DATA so NOT Equal won't Work
Use IS NULL or IS NOT NULL when dealing with NULLs
Using Greater Than Or Equal To (>=)
OR must utilize the Column Name Each Time
Troubleshooting Character Data
Using Different Columns in an AND Statement
Quiz – How many rows will return?
Answer to Quiz – How many rows will return?
What is the Order of Precedence?
Using Parentheses to change the Order of Precedence
Using an IN List in place of OR
The IN List is an Excellent Technique
IN List vs. OR brings the same Results
A Technique for Handling Nulls with a NOT IN List
A Better Technique for Handling Nulls with a NOT IN List
BETWEEN Works for Character Data
LIKE uses Wildcards Percent '%' and Underscore '_'
LIKE command Underscore is Wildcard for one Character
LIKE Command Works Differently on Char Vs Varchar
Troubleshooting LIKE Command on Character Data
Quiz – What Data is Left Justified and What is Right?
Numbers are Right Justified and Character Data is Left
Answer – What Data is Left Justified and What is Right?
An Example of Data with Left and Right Justification
A Visual of CHARACTER Data vs. VARCHAR Data
Use the TRIM command to remove spaces on CHAR Data
TRIM Eliminates Leading and Trailing Spaces
Escape Character in the LIKE Command changes Wildcards
Escape Characters Turn off Wildcards in the LIKE Command
ANSWER – To Find that Wildcard
Chapter 3 – Distinct Vs Group By
Rules of Thumb for DISTINCT Vs GROUP BY
Quiz – How many rows come back from the Distinct?
Answer – How many rows come back from the Distinct?
Chapter 5 – Aggregation Function
Quiz – You calculate the Answer Set in your own Mind
Answer – You calculate the Answer Set in your own Mind
Quiz – How many rows come back?
GROUP BY when Aggregates and Normal Columns Mix
GROUP BY Delivers one row per Group
GROUP BY Dept_No or GROUP BY 1 the same thing
Limiting Rows and Improving Performance with WHERE
WHERE Clause in Aggregation limits unneeded Calculations
Keyword HAVING tests Aggregates after they are Totaled
Keyword HAVING is like an Extra WHERE Clause for Totals
Getting the Average Values Per Column
Average Values Per Column For all Columns in a Table
Three types of Advanced Grouping
Final Answer to Test Your Knowledge on Aggregates
A two-table join using Non-ANSI Syntax
A two-table join using Non-ANSI Syntax with Table Alias
Aliases and Fully Qualifying Columns
A two-table join using Non-ANSI Syntax
Both Queries have the same Results and Performance
Quiz – Can You Finish the Join Syntax?
Answer to Quiz – Can You Finish the Join Syntax?
Quiz – Can You Find the Error?
Answer to Quiz – Can You Find the Error?
Quiz – Which rows from both tables Won't Return?
Answer to Quiz – Which rows from both tables Won't Return?
LEFT OUTER JOIN Example and Results
RIGHT OUTER JOIN Example and Results
FULL OUTER JOIN Example and Results
Which Tables are the Left and Which are the Right?
Answer - Which Tables are the Left and Which are the Right?
INNER JOIN with Additional AND Clause
ANSI INNER JOIN with Additional AND Clause
ANSI INNER JOIN with Additional WHERE Clause
OUTER JOIN with Additional WHERE Clause
OUTER JOIN with Additional AND Clause
OUTER JOIN with Additional AND Clause Example
Quiz – Why is this Considered an INNER JOIN?
The Horrifying Cartesian Product Join
The ANSI Cartesian Join will ERROR
Quiz – Do these Joins Return the Same Answer Set?
Answer – Do these Joins Return the Same Answer Set?
The Self Join with ANSI Syntax
Quiz – Will both queries bring back the same Answer Set?
Answer – Will both queries bring back the same Answer Set?
Quiz – Will both queries bring back the same Answer Set?
Answer – Will both queries bring back the same Answer Set?
How would you Join these two tables?
How would you Join these two tables? You Can't....Yet!
An Associative Table is a Bridge that Joins Two Table
Quiz – Can you Write the 3-Table Join?
Answer to Quiz – Can you Write the 3-Table Join?
Answer – Can you Write the 3-Table Join to ANSI Syntax?
Quiz – Can you Place the ON Clauses at the End?
Answer – Can you Place the ON Clauses at the End?
The 5-Table Join – Logical Insurance Model
Quiz - Write a Five Table Join Using ANSI Syntax
Answer - Write a Five Table Join Using ANSI Syntax
Quiz – Write a Five Table Join Using Non-ANSI Syntax
Answer - Write a Five Table Join Using Non-ANSI Syntax
Quiz –Re-Write this putting the ON clauses at the END
Answer –Re-Write this putting the ON clauses at the END
The Nexus Query Chameleon Writes the SQL for Users.
Date, Time, and Timestamp Keywords
Add or Subtract Days from a date
Conversion Function Templates Continued
A Summary of Math Operations on Dates
Using a Math Operation to find your Age in Years
Find What Day of the week you were Born
Using the ADD_MONTHS Command to Add 1-Year
Using the ADD_MONTHS Command to Add 5-Years
EXTRACT with DATE and TIME Literals
EXTRACT of the Month on Aggregate Queries
A Side Title example with Reserved Words as an Alias
Implied Extract of Day, Month, and Year
DATE_PART Function using an ALIAS
DATE_TRUNC Function using TIME
MONTHS_BETWEEN Function in Action
Intervals for Date, Time, and Timestamp
Troubleshooting The Basics of a Simple Interval
A Complex Time Interval Example using CAST
A Complex Time Interval Example using CAST
An OVERLAPS Example that Returns No Rows
The OVERLAPS Command using TIME
The OVERLAPS Command using a NULL Value
How ANSI Moving SUM Handles the Sort
Quiz – How is that Total Calculated?
Answer to Quiz – How is that Total Calculated?
Moving SUM every 3-rows Vs a Continuous Average
Partition By Resets an ANSI OLAP
The ANSI Moving Window is Current Row and Preceding
How ANSI Moving Average Handles the Sort
Quiz – How is that Total Calculated?
Answer to Quiz – How is that Total Calculated?
Quiz – How is that 4th Row Calculated?
Answer to Quiz – How is that 4th Row Calculated?
Moving Average every 3-rows Vs a Continuous Average
Partition By Resets an ANSI OLAP
Moving Difference using ANSI Syntax
Moving Difference using ANSI Syntax with Partition By
RANK using ANSI Syntax Defaults to Ascending Order
Getting RANK using ANSI Syntax to Sort in DESC Order
PERCENT_RANK() OVER with 14 rows in Calculation
PERCENT_RANK() OVER with 21 rows in Calculation
Quiz – What Causes the Product_ID to Reset?
Answer to Quiz – What Cause the Product_ID to Reset?
COUNT OVER for a Sequential Number
Quiz – What caused the COUNT OVER to Reset?
Answer to Quiz – What caused the COUNT OVER to Reset?
MAX OVER with PARTITION BY Reset
Answer to Quiz – Fill in the Blank
Quiz – How did the Row_Number Reset?
Quiz – How did the Row_Number Reset?
Standard Deviation Functions Using STDDEV / OVER
Standard Deviation Functions and STDDEV / OVER Syntax
Variance Functions Using VARIANCE / OVER
Using VARIANCE with PARTITION BY Example
Using FIRST_VALUE and LAST_VALUE
Using LEAD With and Offset of 2
There are Three Types of Temporary Tables
Aliasing the Column Names in The Derived Table
Multiple Ways to Alias the Columns in a Derived Table
CREATING A Derived Table using the WITH Command
Naming the Derived Table Columns using WITH
The Same Derived Query shown Three Different Ways
Most Derived Tables Are Used To Join To Other Tables
Our Join Example With A Different Column Aliasing Style
Column Aliasing Can Default For Normal Columns
Our Join Example With The WITH Syntax
Answer to Quiz - Answer the Questions
Clever Tricks on Aliasing Columns in a Derived Table
An Example of Two Derived Tables in a Single Query
Syntax For Creating A Temporary Table
Creating and Populating a Temporary Table
A Temporary Table Can Be Used Again and Again
Alternative CREATE TEMPORARY TABLE Option
A CTAS Temp Table to Improve Zone Map Selectivity
Creating a Temp Table as a Cluster Based Table (CBT)
External Tables Data Loading Formats
Exporting Data Off of Netezza into an External Table
Importing Data Into Netezza Using an External Table
Chapter 10 – Sub-query Functions
An IN List is much like a Subquery
An IN List Never has Duplicates – Just like a Subquery
The Final Answer Set from the Subquery
Quiz- Answer the Difficult Question
Answer to Quiz- Answer the Difficult Question
Should you use a Subquery of a Join?
Answer to Quiz- Write the Subquery
Quiz- Write the More Difficult Subquery
Answer to Quiz- Write the More Difficult Subquery
Quiz- Write the Subquery with an Aggregate
Answer to Quiz- Write the Subquery with an Aggregate
Quiz- Write the Correlated Subquery
Answer to Quiz- Write the Correlated Subquery
The Basics of a Correlated Subquery
The Top Query always runs first in a Correlated Subquery
The Bottom Query runs Last in a Correlated Subquery
Quiz- Who is coming back in the Final Answer Set?
Answer- Who is coming back in the Final Answer Set?
Correlated Subquery Example vs. a Join with a Derived Table
Quiz- A Second Chance To Write a Correlated Subquery
Answer - A Second Chance to Write a Correlated Subquery
Quiz- A Third Chance To Write a Correlated Subquery
Answer - A Third Chance to Write a Correlated Subquery
Quiz- Last Chance To Write a Correlated Subquery
Answer – Last Chance to Write a Correlated Subquery
Correlated Subquery that Finds Duplicates
Answer to Quiz- Write the NOT Subquery
Quiz- Write the Subquery using a WHERE Clause
Answer - Write the Subquery using a WHERE Clause
Quiz- Write the Subquery with Two Parameters
Answer to Quiz- Write the Subquery with Two Parameters
How the Double Parameter Subquery Works
More on how the Double Parameter Subquery Works
Quiz – Write the Triple Subquery
Answer to Quiz – Write the Triple Subquery
Quiz – How many rows return on a NOT IN with a NULL?
Answer – How many rows return on a NOT IN with a NULL?
How to handle a NOT IN with Potential NULL Values
How a Correlated Exists matches up
The Correlated NOT Exists Answer Set
Quiz – How many rows come back from this NOT Exists?
Answer – How many rows come back from this NOT Exists?
Chapter 11 - Substrings and Positioning Functions
TRIM for Troubleshooting the CHARACTERS Command
The TRIM Command trims both Leading and Trailing Spaces
Trim and Trailing is Case Sensitive
Trim and Trailing works if Case right
Trim Combined with the CHARACTERS Command
How to TRIM only the Trailing Spaces
How to TRIM Trailing Letters and use CHARACTER_Length
How SUBSTRING Works with NO ENDING POSITION
Using SUBSTRING to move Backwards
How SUBSTRING Works with a Starting Position of -1
How SUBSTRING Works with an Ending Position of 0
An Example using SUBSTRING, TRIM, and CHAR Together
SUBSTRING and SUBSTR are equal, but use different syntax
The POSITION Command finds a Letters Position
The POSITION And STRPOS Do The Same Thing
SUBSTRING and POSITION Used Together In An UPDATE
The POSITION Command is brilliant with SUBSTRING
Quiz – Name that SUBSTRING Starting and For Length
Answer to Quiz – Name that Starting and For Length
Using the SUBSTRING to Find the Second Word On
Quiz – Why Did only one Row Return
Answer to Quiz – Why Did only one Row Return
Miscellaneous Character Functions - ASCII
Miscellaneous Character Functions - CHR
Miscellaneous Character Functions - INITCAP
Miscellaneous Character Functions - REPEAT
Miscellaneous Character Functions - TRANSLATE
Character Padding Functions - LPAD Function
Character Padding Functions - RPAD Function
Chapter 12 – Interrogating the Data
NVL Is Often Used With Calculations
Quiz – Fill in the Answers for the NULLIF Command
Quiz – Fill in the Answers for the NULLIF Command
The Basics of CAST (Convert And STore)
Some Great CAST (Convert And Store) Examples
Some Great CAST (Convert And Store) Examples
Some Great CAST (Convert And Store) Examples
The Basics of the CASE Statements
The Basics of the CASE Statement shown Visually
Valued Case Vs. A Searched Case
Answer - Valued Case Statement
Quiz - Searched Case Statement
Answer - Searched Case Statement
Quiz - When NO ELSE is present in CASE Statement
Answer - When NO ELSE is present in CASE Statement
When an ELSE is present in CASE Statement
When NO ELSE is present in CASE Statement
When an Alias is NOT used in a CASE Statement
When an Alias is NOT used in a CASE Statement
Combining Searched Case and Valued Case
A Trick for getting a Horizontal Case
Views sometimes CREATED for Formatting or Row Security
Another Way to Alias Columns in a View CREATE
Resolving Aliasing Problems in a View CREATE
Resolving Aliasing Problems in a View CREATE
Resolving Aliasing Problems in a View CREATE
CREATING Views for Complex SQL such as Joins
WHY certain columns need Aliasing in a View
Using a WHERE Clause When Selecting From a View
Altering A Table After a View has been Created
A View that Errors After An ALTER
Chapter 14 – Set Operators Functions
An Equal Amount of Columns in both SELECT List
Columns in the SELECT list should be from the same Domain
The Top Query handles all Aliases
The Bottom Query does the ORDER BY (a Number)
Great Trick: Place your Set Operator in a Derived Table
A Great Example of how EXCEPT works
USING Multiple SET Operators in a Single Request
Changing the Order of Precedence with Parentheses
Using UNION to be same as GROUP BY GROUPING SETS
Using UNION to be same as GROUP BY ROLLUP
Using UNION to be the same as GROUP BY Cube
Using UNION to be same as GROUP BY Cube
Chapter 15 – Data Manipulations
What Happens on a Transaction Error?
Can I See My Uncommitted Changes?
Until the Commit Others Can't See Your Changes?
A Different Syntax for the INSERT Statements
These Three Statements are the Same
A Third Way of Doing an INSERT
Netezza Has Implemented the Default Values Clause
Another Syntax for the INSERT/SELECT
INSERT/SELECT Used To CREATE A Data Mart
An UPDATE With Multiple WHERE and AND Clauses
An UPDATE With Multiple WHERE and AND Clauses
DELETE Through a Subquery or Join
DELETE Through a Subquery And A Join Examples
How to Undo a Delete In Action
Chapter 16 – Tables, DDL, and Data Types
Netezza Tables - Distribution Key or Random Distribution
Table CREATE Examples with 4 different Distribution Keys
The Worst Mistake You Can Make For A Distribution Key
Good things to know about Table and Object Names
Netezza Data Types in More Detail
How To Query and See Non-Active Rows
Column Level Constraint Example
Defining Constraints at the Table Level
Utilizing Default Values for a Table
Using the CTAS (Create Table AS) Table For Co-Location
Altering a CTAS Table to Rename It
FPGA Card and Zone Maps – The Netezza Secret Weapon
How A CTAS with ORDER BY Improves Queries
A CTAS Major Sort Benefits over the Minor Sort
Drop Table, Truncate, and Delete Compared
Creating and Dropping a Netezza Database
How to Determine the Database you are in?
Reserved Words to find out about a User
Chapter 17 – Statistical Aggregate Functions
Chapter 18 – Stored Procedure Functions
Creating and Executing a Stored Procedure
Netezza Provides Multiple Ways to Run the Stored Procedure
You Can Have Multiple BEGIN and END statements
How to Declare and Set a Variable
Declaring a Variable With A Value
Input Parameters Using Character Data
Calling a Procedure With Multiple Input Parameters
An Easier Way for IF THEN ELSE is ELSIF or ELSEIF
Using Loops in Stored Procedures
Using Loops with Different EXIT strategies
Looping With The WHILE Statement
Chapter 19 – Nexus Query Chameleon
Watch the Video on the new Nexus Super Join Builder
How to Customize your System Tree View
Introducing the new Nexus Super Join Builder
Define your Joins and tell Nexus to "Add and Remember Me"
Nexus knows what Tables Join together
Nexus Presents Tables and their columns in Color
Nexus Builds your SQL Automagically
Nexus can Cube a Table and Join to Everything Possible
Nexus can Cube a Table and Join to Everything Possible
The Cube SQL created Automagically
Manipulate the Columns with the Columns Tab
Single Click and ORDER BY using the Sort Tab
The SQL Tab reflects the changes we make in all other Tabs
WHERE Tab shows Tables Indexes
The Answer Set Tab shows the Results
The Answer Set Tab shows the Results
The Answer Set Tab shows the Results
The Answer Set Tab shows the Results
The Metadata Tab shows Metadata
Nexus Makes a View look like a Table
Nexus Joins Views to other Views in seconds
Nexus can Cube a View and Join to all other related Views
The Cube SQL created on Views is done Automagically
Views with the Underlying Indexes of the Base Tables
WHERE Tab shows Views Underlying Base Table Indexes
After an Answer Set Returns, you can do many things
After an Answer Set Returns, Perform OLAP Calculations
After an Answer Set Returns, you can Graph and Chart
Users Who Want to Load the Model
Users Who Want to Load the Model (Continued)
How Custom Joins Will Look in the Super Join Builder
Loading an ERwin Model (Continued)
Attaching The ERwin Model (Continued)
Managing The ERwin Model (Continued)
Saving an Answer Set in another Format
Sandbox – How to Create a Sandbox (1 of 5)
Sandbox - Join Answer Sets from different Systems (2 of 5)
Sandbox - Join Answer Sets from different Systems (3 of 5)
Sandbox - Join Answer Sets from different Systems (4 of 5)
Sandbox - Join Answer Sets from different Systems (5 of 5)
18.118.20.156