Learn SQL by writing SQL

53 free lessons on SQL and SQL Server, from your first query to triggers. Many examples run right here in your browser, with nothing to install.

Try it: how much has each customer of the course shop spent?

PostgreSQL in your browser · Ctrl+Enter to run · changes are rolled back afterwards

The course, step by step

Seven parts, in order. Each one builds on the previous, but you can jump into whichever you need.

  1. Introduction to SQL Server

    What SQL is, how a relational database is organised and how to install SQL Server to follow the course.

    8 lessons Start with: Introduction to SQL and SQL Server

  2. Creation and management of SQL databases

    Build the course shop database and learn to insert, update and delete rows.

    12 lessons Start with: CREATE DATABASE statement in SQL

  3. SQL query execution

    SELECT, filters, sorting, grouping, JOIN and subqueries. Every lesson has runnable examples.

    10 lessons Start with: SELECT statement in SQL

  4. Advanced SQL queries

    CTEs, EXISTS, window functions such as ROW_NUMBER and LAG, running totals and PIVOT: the SQL that comes up in interviews.

    7 lessons Start with: CTE in SQL: the WITH clause

  5. Language elements

    Variables, operators, IF, WHILE, transactions and error handling in Transact-SQL.

    8 lessons Start with: Variables in Transact SQL

  6. SQL functions

    SQL Server built-in functions and how to write your own.

    5 lessons Start with: Built-in functions in SQL

  7. Advanced SQL elements

    Views, stored procedures and triggers: logic that lives inside the database.

    3 lessons Start with: Views in SQL

SQL and its dialects

SQL is the language. SQL Server, PostgreSQL and MySQL are databases that speak it, each with its own accent: the core is the same and the details change.

SQL Server

Lesson syntax

Microsoft's database. Widely used by companies built on the Microsoft ecosystem, from Excel and Power BI to Azure.

Its SQL
Transact-SQL (T-SQL)
Where you will find it
Banking, insurance, public sector and .NET applications
In this course
The course's reference: lesson syntax is T-SQL.

PostgreSQL

Editor engine

Open source, very close to the standard and with powerful extensions such as PostGIS. A favourite of many startups and data teams.

Its SQL
PostgreSQL SQL, with PL/pgSQL for procedures
Where you will find it
Web applications, data analysis and cloud services
In this course
It's what the page editors run, right in your browser.

MySQL

Open source and owned by Oracle. For years it was the database of the web: it powers WordPress and much of shared hosting.

Its SQL
MySQL SQL
Where you will find it
Websites, e-commerce and WordPress
In this course
The lesson queries work almost the same; details change, such as LIMIT instead of TOP.

MariaDB

A fork of MySQL created in 2009 by its original author. It's compatible with MySQL in almost everything and is the default in several Linux distributions.

Its SQL
MariaDB SQL, almost identical to MySQL
Where you will find it
Linux servers and websites that used to run MySQL
In this course
What you learn for MySQL also applies to MariaDB.

SQLite

A database in a single file, with no server. It's built into phones, browsers and thousands of applications.

Its SQL
SQLite SQL, with no stored procedures
Where you will find it
Mobile apps, browsers, prototypes and local analysis
In this course
Great for practising without installing anything: almost every SELECT in the course works as is.

Oracle Database

Oracle's commercial database, designed for very large and critical systems.

Its SQL
Oracle SQL, with PL/SQL for procedures
Where you will find it
Large enterprises, telecoms and banking
In this course
The course's SELECT, JOIN and window functions are standard SQL and apply the same way.

See the syntax differences side by side

Frequently Asked Questions

In SQLearning we will learn in a didactic way with replicable examples all the most important concepts of Transact-SQL management, from the simplest to the most advanced ones

What does SQLearning offer?

In SQLearning we will learn in a didactic way,with replicable examples, the most important concepts of handling Transact-SQL, from the simplest one to the most advanced.

Why Transact-SQL and not SQL?

With Transact-SQL we will learn the entire SQL standard, plus the characteristics of said language (Stored Procedures, Triggers,...).

Why SQL Server as an alternative to ORACLE?

The answer largely depends on the needs of each user. However, from SQLearning we facilitate the learning of Transact-SQL since it is used more in small and medium-sized companies while ORACLE is more frequently used in large organizations.

Why is so important to learn SQL?

The use and handling of databases is present in innumerable applications and technologies, which makes SQL one of the most demanded programming languages today.

Who should learn SQL?

Any person who wants to work with data management (analysts, data scientists...), backend-fullstack developers, mobile application developers... In addition, SQL should be learned by anyone interested in the use and management of databases.

Can SQL be used in other programming languages?

Yes, SQL is often used externally from other programming languages. C, Java or Python are some examples.