This SQL tutorial helps you get started with SQL quickly and effectively through practical examples.
If you are a software developer, database administrator, or data analyst who wants to use SQL to answer questions through data, this tutorial is a great start.
Each topic is covered clearly and concisely with many practical examples so that you can both truly understand the concept and know how to apply it to solve the problems effectively.
SQL stands for structured query language designed to manipulate data in relational databases. Today, SQL is one of the most common programming languages for accessing data in the databases.
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 – how to query data from a single table using the simplest form of the SELECT statement.
- Using SQL Aliases – make your query shorter and more understandable.
- SELECT DISTINCT – show you how to remove duplicates from the result set returned by the SELECT statement.
- LIMIT – constrain a number of rows returned by a query using the LIMIT and OFFSET clause.
Section 3: Filtering Data
- WHERE Clause – filter data based on specified conditions using the WHERE clause.
- AND operator – combine multiple Boolean expressions using the AND clause to create a flexible condition.
- 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 equals a list of values.
- LIKE Operator – do you want to query data based on a specific pattern? use the LIKE operator.
- 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 using the NOT operator.
Section 4: Sorting Data
- ORDER BY Clause – sort the data in ascending or descending order.
Section 5: Conditional Expressions
- CASE Expression – add logic to the SQL statements.
Section 6: Joining Multiple Tables
- INNER JOIN – introduce you to the join concept and show you how to use the INNER JOIN clause to query 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 where or not the rows has a matching row from another table.
- CROSS JOIN – produce a Cartesian product of rows in 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
- Overview of Aggregate functions – show you the commonly used aggregate functions.
- AVG Function – calculate the average value of a set.
- COUNT Function – return the number of items of a set.
- SUM Function – return the sum all or distinct items of a set.
- MAX Function – find the maximum value in a set.
- MIN Function – find the minimum value in a set.
Section 8: Grouping Data
- GROUP BY clause – combine rows into groups and apply an aggregate function to each group.
- ROLLUP and CUBE – generate subtotals for grouping columns.
- HAVING Clause – specify a condition for filtering groups summarized by the GROUP BY clause.
Section 9: Using SET Operators
- UNION and UNION ALL Operators – combine result set of two or more queries into a single result set using the UNION and UNION ALL operators.
- INTERSECT Operator – return the intersection of two or more queries using the INTERSECT operator.
- MINUS Operator – 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 flexible query for retrieving data.
- EXISTS – discuss the EXISTS operator and show you how to use it 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 value in a set.
Section 11: Data Manipulation Language (DML) Statements
- INSERT statement – insert one or more rows into a table.
- UPDATE statement – update one or more rows in a table.
- DELETE statement – delete data from a table permanently.
- COMMIT and ROLLBACK statements – handle transactions using the COMMIT and ROLLBACK statements
Section 12: Data Definition Language (DDL) Statements
- CREATE TABLE Statement – create a new table in the database using the CREATE TABLE statement.
- ALTER TABLE Statement – modify the structure of an existing table with the ALTER TABLE statement.
- DROP TABLE Statement – remove redundant tables permanently using the DROP TABLE statement.
- TRUNCATE TABLE – delete all data in a big table fast and efficiently.
Section 13: Constraints
- PRIMARY KEY Constraint – show you how to define a primary key for a table.
- FOREIGN KEY Constraint – walk you through the steps of enforcing the relationship between data in two tables using the foreign key constraint.
- UNIQUE Constraint – allow you to ensure the uniqueness of values in a column or a set of columns.
- NOT NULL Constraint – ensure that the values that being inserted or updated into a column are not NULL
- CHECK Constraint – validate the data before it is inserted or updated in one or more columns based on a Boolean expression.