Welcome to our PostgreSQL interactive SQL Tutorial! We’ve designed this specifically for tech-savvy folks to learn enough SQL to be able to do their own analysis and data fetching.
We’ve added a big innovation to our tutorial that makes it quite different: Because we believe the best way to learn SQL is by playing around, we’ve created an interactive SQLBox for you to follow along and play with writing queries from the very start. The SQLBox takes your input and runs it against a live PostgreSQL database that we’re hosting.
The SQLBox is embedded right in to the lessons themselves. Some of them have a checkbox to their left. These are ones that have a correct answer to them. See if you can get all of them correct!
Best of luck to you! I hope you learn a great amount from our lessons here. If you have any comments, feedback, suggestions, etc. please drop us a line at firstname.lastname@example.org
SQL Tutorial Lessons
Quick Introductory SQL Concepts
Learn how to use SQL with your PostgreSQL database. In this interactive SQL data tutorial, get an introduction that is designed to get you querying your PostgreSQL database as quickly as possible. Learn SQL basics, tables and SQLbox.
Learn the SELECT SQL statement with your PostgreSQL database in this interactive SQL data tutorial. The SELECT statement is a basic SQL command that easily allows you to interact with the data in your PostgreSQL database.
This interactive SQL tutorial will explain the FROM command with syntax and use cases on how to interact with your data in the PostgreSQL database. Learn how to use the SQL FROM command by following the steps in this interactive tutorial.
Learn how to use the SQL ORDER BY command in PostgreSQL. The ORDER BY command is used to sort your result data in ascending or descending order. Follow the interactive SQL tutorial to use cases and best practices for the ORDER BY command.
LIMIT and OFFSET
Learn how to LIMIT the number of results that are returned you can simply use the LIMIT SQL command at the end of the query to specify. You can use the LIMIT command on your PostgreSQL database. Read the tutorial to learn more.
Browsing the SCHEMA
The word SCHEMA is used to describe a collection of tables and their relationships in your database. In this interactive SQL tutorial, learn how to browse the SCHEMA in a PostgreSQL database by using SQL to query your data.
Basic SQL Practice Grounds
Now that you’ve gone through our PostgreSQL interactive SQL tutorials, you’ve got the basic SQL fundamentals that you can apply to your data and databases. Put that knowledge to use in these SQL practice exercises.
Mid Level SQL
Learn how to use the SQL WHERE command in PostgreSQL. In this interactive SQL tutorial, learn the syntax of the WHERE command and best practices on using it for data analysis and exploration against your PostgreSQL database.
Learn about Operator in SQL, which are used to specify conditions in a SQL statement and as conjunctions for multiple conditions in a SQL statement. In this interactive SQL tutorial, learn how to use an Operator in a SQL query.
Learn about the COUNT function in SQL. The COUNT command is a commonly used aggregation function that takes whatever you give it and returns the count of how many there are. This interactive SQL tutorial will teach you how to COUNT.
The GROUP BY SQL statement is used to aggregate functions like COUNT, MAX, MIN, SUM and AVG to group results into columns. In this interactive SQL tutorial, learn how to use the GROUP BY statement in your SQL queries in PostgreSQL.
JOIN Relationships and JOINing Tables
A JOIN SQL statement combines two data from two tables together. In this interactive SQL tutorial, learn how to use the JOIN statement in your SQL queries against your PostgreSQL database to analyze your data. Read more to learn.
DATE and TIME Functions
DATE and TIME values in PostgreSQL have a whole special set of functions and operators for their proper use. Learn how to use dates in PostgreSQL in this interactive SQL tutorial, so you can get the DATE and TIME of your data analysis.
Mid Level SQL Practice Grounds
Now that you’ve gone through our PostgreSQL interactive SQL tutorials, you’ve got mid-level SQL fundamentals that you can apply to your data and databases. Put that knowledge to use in these SQL practice exercises.
PostgreSQL Tutorial Completed
Congratulations on completing your learning in SQL for PostgreSQL. Continue your SQL education in testing out the SQL editor in Chartio that enables you to analyze your data from disparate data sources in one dashboard. Start a trial.
Help with Common PostgreSQL Errors
When working with SQL you’re going to run into a lot of errors. This is a guide to help you with common PostgreSQL database errors when writing SQL queries. Continue reading to troubleshoot your errors and fix them.
How To Generate Random Data in PostgreSQL
You can generate random values in SQL using the following instructions.
How to Export PostgreSQL Data to a CSV or Excel File
Learn how to export PostgreSQL data to a CSV or Excel file. Follow these instructions to copy full data tables, copy a query result set and opening your CSV file. Read more to learn.
Q: Why did you build this SQL Tutorial?
Our company Chartio is on a mission to ensure that anyone (not just engineers and data scientists) can explore and understand data. Half of that mission is about creating an easy to use product for data exploration, and the other half is about educating because no matter how easy we make our tools, there is still much to teach.
I wrote this tutorial because I wasn’t comfortable suggesting any existing SQL Tutorials to customers or friends. Most of them start with a lengthy process of installing, creating, structuring, and loading a database yourself. Others are purely reference based and offer no process or dataset to follow along yourself.
Q: Who is this tutorial for?
This tutorial is built specifically for technically savvy, but non-engineer types who know their way around tools like Excel, but may be new to databases. That’s not to say it’s not useful for new engineers or students on their way to becoming DBAs, but if you’re one of those you’re just not our primary target here.
Q: Who wrote this SQL Tutorial?
I’m Dave, the Founder and CEO of Chartio. I programmed the interactive SQLBox and wrote the core of this tutorial myself. Much of my team has and will continue to continuously build more lessons and extra content.
With thousands of new queries being added in Chartio every day we have a unique set of knowledge on what parts of SQL are the most used, and where people are more likely to get hung up.
Q: Why is it for PostgreSQL specifically?
Most tutorials out there are for generic SQL. We thought we’d be a little more specific and plan to eventually build a specific (though fairly similar) tutorial for each of the major database engines.
Q: What was wrong with the other tutorials?
Many tutorials require users to first learn how to install, configure, and import data into their database before getting going with common queries.
Others are purely text based, and offer no interactivity to play/learn along.
We solve both these major issues by having an interactive SQL editor running against a live PostgreSQL database. The lessons have the SQL editor built into them, and have challenges along the way.
Q: What’s so great about the SQLBox?
Having an interactive SQL interface running against a live PostgreSQL server allows a few key advantages:
- Interactive SQL Interface (SQLBox)
- No setup needed - start with writing queries!
- Database (PostgreSQL) specific tutorial
- SQL quizzes/challenges as you go along and at the end of each section.
Q: What is Chartio?
Chartio is a company and a product on a mission to enable anyone in a company (not only the data scientists) to explore and understand their data. If you’re interested you can see more about our product here or signup for our free trial here.
Q: Why so colloquial?
The style of this tutorial was inspired by Joe Burns, Ph.D and his classic HTMLGoodies that was by far the best written, most useful, and fun tutorial I’ve ever read.