SQL for beginners: learn the basics in one weekend

SQL for beginners: learn the basics in one weekend

SQL is the most practical data skill you can learn after spreadsheets.

it reads like English. it is available in every database, every analytics platform, and every data tool. once you know it, you can pull exactly the data you need from any system that stores data — without waiting for an engineer to do it for you.

this guide teaches the five commands that cover 80% of real-world SQL work, shows you how to set up a free practice environment with no installation, and walks you through answering real business questions with SQL.

what SQL is and why non-developers use it

SQL (Structured Query Language) is a language for asking questions from a database. a database is like a collection of interconnected spreadsheets — tables with rows and columns — but designed to hold millions of rows without slowing down.

you write a question in SQL:

SELECT product, SUM(revenue) as total_revenue
FROM orders
GROUP BY product
ORDER BY total_revenue DESC;

the database returns:

product total_revenue
Widget A 45,200
Widget B 38,100
Widget C 12,500

this is the same question a pivot table answers in Excel — but SQL can do it on 10 million rows in seconds, join data from multiple tables, and run as a scheduled report automatically.

who uses SQL without being a developer:
– marketing analysts pulling campaign performance from a database
– e-commerce operators querying order data from their platform
– SaaS founders querying Supabase or Postgres directly
– data analysts at every company size who need answers faster than waiting for a report

how to set up a free SQL practice environment in 10 minutes

you do not need to install anything to start practicing SQL.

option 1: SQLiteOnline.com

go to sqliteonline.com. you will see a SQL editor in the browser with a sample database already loaded. type a query and click Run. no account required.

option 2: DB Fiddle (dbfiddle.uk)

lets you choose your database engine (SQLite, PostgreSQL, MySQL) and create tables manually to practice with. good for testing specific queries.

option 3: Google BigQuery sandbox

if you have a Google account, BigQuery’s sandbox mode is free with no credit card required (up to 1TB of queries per month). it comes with public datasets you can query immediately, including Google Analytics sample data.

go to console.cloud.google.com → BigQuery → select a public dataset.

for practice data:

download any CSV from Kaggle or Data.gov. in SQLiteOnline.com, click “Open DB” → choose your CSV → it creates a table automatically. you are now running SQL against real data.

the five SQL commands that cover 80% of real queries

1. SELECT and FROM — pick what you want to see

SELECT column1, column2
FROM table_name;

this retrieves columns from a table. to see all columns, use *:

SELECT *
FROM orders;

to give a column a different name in the output, use AS:

SELECT product_name AS product, unit_price AS price
FROM products;

2. WHERE — filter rows

SELECT *
FROM orders
WHERE region = 'North America';

WHERE filters which rows are included. you can combine conditions:

SELECT *
FROM orders
WHERE region = 'North America'
  AND revenue > 1000;

useful WHERE operators:
= equals
> greater than, < less than, >= greater or equal
<> or != not equal
IN ('value1', 'value2') — matches any of a list
LIKE '%pattern%' — matches text containing a pattern
BETWEEN 100 AND 500 — range filter
IS NULL / IS NOT NULL — filter for blank values

example:

SELECT *
FROM customers
WHERE country IN ('Singapore', 'Malaysia', 'Thailand')
  AND signup_date >= '2025-01-01';

3. GROUP BY — summarize by category

GROUP BY is the SQL equivalent of a pivot table. it groups rows with the same value in a column and runs a calculation on each group.

SELECT product, SUM(revenue) as total_revenue
FROM orders
GROUP BY product;

aggregate functions used with GROUP BY:
SUM() — total
COUNT() — how many rows
COUNT(DISTINCT column) — how many unique values
AVG() — average
MAX() / MIN() — highest / lowest value

example — orders per customer per month:

SELECT customer_id,
       DATE_FORMAT(order_date, '%Y-%m') as month,
       COUNT(*) as order_count,
       SUM(revenue) as monthly_revenue
FROM orders
GROUP BY customer_id, month
ORDER BY customer_id, month;

4. ORDER BY — sort the results

SELECT product, SUM(revenue) as total_revenue
FROM orders
GROUP BY product
ORDER BY total_revenue DESC;

DESC sorts highest to lowest. ASC sorts lowest to highest (the default if you do not specify).

5. LIMIT — cap the number of rows returned

SELECT *
FROM orders
ORDER BY revenue DESC
LIMIT 10;

always use LIMIT when exploring a large table for the first time. running SELECT * FROM orders on a 10-million-row table without LIMIT can crash a browser or cost money on cloud databases.

your first real analysis: answering business questions with SQL

question: what is the total revenue by product, ranked highest to lowest?

SELECT product_name,
       SUM(revenue) as total_revenue
FROM orders
GROUP BY product_name
ORDER BY total_revenue DESC;

question: how many new customers signed up each month in 2025?

SELECT DATE_FORMAT(signup_date, '%Y-%m') as month,
       COUNT(*) as new_customers
FROM customers
WHERE signup_date BETWEEN '2025-01-01' AND '2025-12-31'
GROUP BY month
ORDER BY month;

question: which customers have not placed an order in the last 90 days?

SELECT customer_id, email, last_order_date
FROM customers
WHERE last_order_date < DATE_SUB(NOW(), INTERVAL 90 DAY)
   OR last_order_date IS NULL
ORDER BY last_order_date ASC;

question: what is the average order value by region?

SELECT region,
       AVG(order_value) as avg_order_value,
       COUNT(*) as order_count
FROM orders
GROUP BY region
ORDER BY avg_order_value DESC;

HAVING — filter after GROUP BY

WHERE filters rows before grouping. HAVING filters groups after grouping.

example — only show products with more than 100 orders:

SELECT product_name,
       COUNT(*) as order_count,
       SUM(revenue) as total_revenue
FROM orders
GROUP BY product_name
HAVING order_count > 100
ORDER BY total_revenue DESC;

you cannot use WHERE order_count > 100 here because order_count is a calculated value that does not exist until after GROUP BY runs. HAVING lets you filter on those calculated values.

JOIN — combine data from multiple tables

once you know SELECT, WHERE, GROUP BY, and ORDER BY, the next skill is JOIN — combining rows from two tables.

example: your orders table has a customer_id but not the customer’s name. the customers table has the name.

SELECT orders.order_id,
       customers.name,
       customers.email,
       orders.revenue
FROM orders
JOIN customers ON orders.customer_id = customers.id;

this combines every order row with the matching customer row, giving you one combined result.

types of JOIN:
JOIN / INNER JOIN: only rows that have a match in both tables
LEFT JOIN: all rows from the left table, plus matching rows from the right table (unmatched right rows become NULL)
RIGHT JOIN: the reverse
FULL JOIN: all rows from both tables

for most business analysis, INNER JOIN and LEFT JOIN cover everything you need.

where to practice SQL for free after this article

three free platforms worth using regularly:

SQLZoo (sqlzoo.net): interactive exercises with immediate feedback. starts with basic SELECT and works up to complex multi-table queries. no signup required.

Mode Analytics SQL Tutorial (mode.com/sql-tutorial): business-focused exercises using real-style datasets. better for analysts learning to think in SQL rather than just learn syntax.

LeetCode SQL problems (free tier): competitive practice problems. useful if you are preparing for a data analyst job interview.

for a comparison of all free and paid SQL learning platforms, see best SQL learning platforms 2026.

once you are comfortable with SQL basics, the natural next step is Python for data analysis — which adds data visualization and statistical capabilities beyond what SQL handles:
Python for business data analysis — beginner guide
Python pandas tutorial for non-programmers