Introduction to SQL

Who is this course for?

Much of the world’s valuable data is locked away in databases and SQL is the key to unlocking it. This course is for people who need to extract this data into their analyses and projects.

Learning Objectives

After the course, delegates will be able to write SQL statements to extract data from databases and transform it into the shape needed for their business purposes.

Course Length – 2 days

Course Content

  • Introduction to SQL and Databases. Why is SQL important?  SQL’s declarative nature
  • Getting Started. The structure of a simple SELECT statement explained.  Filter data with the WHERE clause. Common aggregation functions: e.g. COUNT(), SUM(), AVG()
  • Tables and Relationships.  The structure of tables (columns, data types, nullability, cardinality, primary keys) and relationships between tables (common columns, foreign keys, referential integrity)
  • Get data from several tables using JOINs. Types of JOIN (INNER, LEFT, others)
  • Dates and Calendars. SQL date functions to get the year, quarter, month from a date. SQL date arithmetic; calculate durations between two dates
  • Subqueries and CTEs.  Simple and Correlated subqueries, CTEs and the WITH clause – and why this is often a better alternative to a subquery
  • CASE statements.  The basic CASE WHEN THEN ELSE END structure.  Typical uses: counting rows that meet a certain criterion.  Using CASE with aggregate functions e.g. calculating percentages
  • Window functions. The OVER() clause, the PARTITION clause – apply the windows (and group/ aggregate) over the distinct values in one or more columns and the ORDER BY clause – example of use: e.g. ranking by category
  • Using SQL with popular visualisation tools like Power BI
  • Changing Data.  The INSERT, UPDATE and DELETE statements

Pre-requisites

None.  This is an introduction to SQL for beginners.