You can sign up to the Udacity free course here

Udacity offer a great free SQL course designed to take complete beginners to confident analysts in just 4 weeks. The course is a self paced online course comprised of a series of tutor-led videos, interactive activities and downloadable resources. We recommend you complete the first 3 modules for a basic understanding before you start using Ravelin’s DWH. The time estimates below are conservative; fast learners will do this much quicker!

The course will cover the following topics:

  1. Basic SQL - 4 hrs

    Gain basic SQL knowledge and learn to structure a query and filter data from a single table. You’ll also get comfortable with statements such as WHERE, LIKE, IN, BETWEEN and AND.

  2. SQL Joins - 5 hrs

    Learn to bring data from multiple tables together and the different types of joins you can use.

  3. SQL Aggregations - 6 hrs

    Aggregate data with basic commands such as SUM, AVG and COUNT.

  4. SQL Subqueries and temporary tables - 5 hrs

    Answer more complex business questions using nested querying methods

  5. SQL Data Cleaning - 5 hrs

    Fix incorrect, incomplete, duplicate or otherwise erroneous data in the data set.

  6. Advanced SQL Window Functions - 3 hrs

    Compare one row to another without joins using powerful SQL concepts

  7. Advanced SQL JOINs and Performance Tuning - 3 hrs

    Advanced joins and how to make queries run quickly across giant datasets.

Cheatsheet

Command clauses

SELECT Select data from database

FROM Specify the table you are pulling from

WHERE Filter query to match a condition

AS Rename column or table with alias

JOIN Combine rows from two or more tables

AND Combine query conditions (all must be met)

OR Combine query conditions (one must be met)

LIMIT Limit rows returned (See also FETCH and TOP)

IN Specify multiple values when using where

CASE Return value on a specified condition

IS NULL Return only rows with a NULL value

LIKE Search for patterns in column

COMMIT Write transaction to database

ROLLBACK Undo a transaction block

ALTER TABLE Add/Remove columns from table

UPDATE Update table data

CREATE Create TABLE, DATABASE, INDEX or VIEW

DELETE Delete rows from table

INSERT Add single row to table

DROP Delete TABLE, DATABASE, or INDEX

GROUP BY Group data into logical sets

ORDER BY Set order of results - ASC or DESC

HAVING Same as WHERE but filters groups

COUNT Count number of rows

SUM Return sum of column

AVG Return average of column

MIN Return min value of column

MAX Return max value of column

Order of execution

  1. FROM
  2. WHERE
  3. GROUP BY
  4. HAVING
  5. SELECT
  6. ORDER BY
  7. LIMIT

Joining tables

Screenshot 2025-01-09 at 08.54.35.png

Wild cards used with WHERE/IN/LIKE

% Zero or more characters bl% finds bl, black, blue, and blob
_ A single character h_t finds hot, hat, and hit
[] Any single character within the brackets h[oa]t finds hot and hat, but not hit
^ Any character not in the brackets h[^oa]t finds hit, but not hot and hat
- Any single character within the specified range c[a-b]t finds cat and cbt

Examples

Querying a Single Table - Example