SQL Tutorial

This SQL tutorial helps you get started with SQL quickly and effectively through many practical examples.

If you are a software developer, database administrator, data analyst, or data scientist who wants to use SQL to analyze data, this tutorial is a good start.

Each topic is covered clearly and concisely with many practical examples that help you truly understand the concept and apply it to solve the data challenges more effectively.

SQL stands for Structured Query Language designed to manipulate data in the Relational Database Management Systems (RDBMS).

Today, SQL is one of the most common programming languages for interacting with data.

Section 1: Introduction to SQL

  • What is SQL – give you a brief overview of the SQL language and its popular dialects.
  • SQL Syntax – provide you with the syntax of the SQL language.
  • SQL Sample Database – introduce you to an HR sample database.

Section 2: Querying Data

  • SELECT Statement – show you how to query data from a single table by using the simplest form of the SELECT statement.

Section 3: Sorting Data

  • ORDER BY Clause – sort the data by one or more columns in the ascending and/or descending order.

Section 4: Filtering Data

  • DISTINCT  – show you how to remove duplicates from the result set.
  • LIMIT – constrain a number of rows returned by a query using the LIMIT and OFFSET clause.
  • FETCH – learn how to skip N rows in a result set before starting to return any rows.
  • WHERE Clause – filter data based on specified conditions.
  • Comparison operators – learn how to use the comparison operators including greater than, greater than or equal, less than, less than or equal, equal, and not equal to form the condition in the WHERE clause.
  • Logical operators – introduce the logical operators and how to use them to test for the truth of a condition.
  • AND operator – combine multiple Boolean expressions using the AND logical operator.
  • OR operator – show you how to use another logical operator OR to combine multiple Boolean expressions.
  • BETWEEN Operator – guide you to use the BETWEEN operator to select data within a range of values.
  • IN Operator – show you how to use the IN operator to check whether a value is in the list of values.
  • LIKE Operator –  query data based on a specified pattern.
  • IS NULL Operator – introduce the NULL concepts and show you how to check whether an expression is NULL or not.
  • NOT operator – show you how to negate a Boolean expression by using the NOT operator.

Section 5: Conditional Expressions

Section 6: Joining Multiple Tables

  • SQL Aliases – make your query shorter and more understandable.
  • INNER JOIN – introduce you to the join concept and show you how to use the INNER JOIN clause to combine data from multiple tables.
  • LEFT OUTER JOIN – provide you with another kind of joins that allows you to combine data from multiple tables.
  • FULL OUTER JOIN – join multiple tables by including rows from both tables whether or not the rows have matching rows from another table.
  • CROSS JOIN – produce a Cartesian product of rows of the joined tables using the cross join operation.
  • SELF JOIN – join a table to itself using either the inner join or left join clause.

Section 7: Aggregate Functions

  • Aggregate functions – introduce you to the most commonly used aggregate functions in SQL including AVG, COUNT, SUM, MAX, and MIN.
  • AVG – calculate the average value of a set.
  • COUNT – return the number of items in a set.
  • SUM – return the sum of all or distinct items of a set.
  • MAX – find the maximum value in a set.
  • MIN – find the minimum value in a set.

Section 8: Grouping Data

  • GROUP BY– combine rows into groups and apply an aggregate function to each group.
  • HAVING – specify a condition for filtering groups summarized by the GROUP BY clause.
  • GROUPING SETS – generate multiple grouping sets.
  • ROLLUP – generate multiple grouping sets considering the hierarchy of the input columns.
  • CUBE – generate multiple grouping sets for all possible combination of the input columns.

Section 9: SET Operators

  • UNION and UNION ALL – combine result sets of two or more queries into a single result set using the UNION and UNION ALL operators.
  • INTERSECT  – return the intersection of two or more queries using the INTERSECT operator.
  • MINUS – subtract a result set from another result set using the MINUS operator.

Section 10. Subquery

  • Subquery – show you how to nest a query inside another query to form a more flexible query for querying data.
  • Correlated Subquery – introduce you to the correlated subquery which is a subquery that uses values from the outer query.
  • EXISTS – show you how to check for the existence of the row returned from a subquery.
  • ALL – illustrate how to query data by comparing values in a column of the table with a set of columns.
  • ANY – query data if a value in a column of a table matches one of the values in a set.

Section 11: Modifying data

  • INSERT – insert one or more rows into a table.
  • UPDATE – update existing data in a table.
  • DELETE – delete data from a table permanently.

Section 12: Working with table structures

Section 13: Constraints

  • PRIMARY KEY – show you how to define a primary key for a table.
  • FOREIGN KEY – walk you through the steps of enforcing the relationship between data in two tables using the foreign key constraint.
  • UNIQUE – ensure the uniqueness of values in a column or a set of columns.
  • NOT NULL  – ensure that the values inserted into or updated to a column are not NULL.
  • CHECK – validate data before it is stored in one or more columns based on a Boolean expression.