SQL Essentials for Data Analysis: How to Practice Analytical SQL in Google Colab and SQLite Without Installing a DatabaseNote · digest for December 1
Watercolor and ink illustration about learning analytical SQL in Google Colab and SQLite: an open browser notebook with query cells, a database cylinder, a pencil, and a coffee cup.
Note3 sections≈ 5 min

SQL Essentials for Data Analysis: How to Practice Analytical SQL in Google Colab and SQLite Without Installing a Database

In 2026, it's easy to assume it's too late to learn SQL by hand: describe the task to an AI and grab the query. In reality, analytics and dashboards still run on SQL, and generated code turns into a lottery if you can't verify the numbers. The good news is zero setup friction: you don't need local PostgreSQL or MySQL to practice CTEs and window functions — everything runs in your browser.

Why Write Queries Yourself When AI Generates Them?

An AI can easily output a clean SELECT that runs with zero errors and returns a plausible table. Leave out one JOIN condition or let duplicates slip in, and your report is off by millions. To catch the bug and prompt the AI properly, you need to read and debug SQL yourself.

That's the idea behind the free 8-hour video course SQL Essentials for Data Analysis by Benjamin Bennett Alexander (also paired with the book SQL Essentials for Data Analysis: A 50-Day Hands-on Challenge Book). Queries are written live from scratch, complete with real typos and live debugging — far more useful for practice than sterile slides.

A Sandbox in One Minute: Google Colab, SQLite, and JupySQL

Learning often stalls before the first query because you have to install a DB server, configure permissions, and set up a client. Pairing Google Colab with SQLite skips all of that. Google Colab gives you free browser-based Jupyter notebooks with Python preinstalled and Google Drive storage. SQLite is an embedded single-file or in-memory database already built into Python via sqlite3.

The course uses the older ipython-sql extension for SQL cells, but today JupySQL is the better choice — an actively maintained successor compatible with modern SQLAlchemy. Open a new Colab notebook, click Connect, and run one cell:

# Install JupySQL and connect to a local SQLite database in Colab
%pip install jupysql --quiet
%load_ext sql
%sql sqlite:///analytics_demo.db

Cells starting with %%sql immediately act as a SQL editor with formatted table output (or, without extensions, you can use plain Python via sqlite3.connect("analytics_demo.db")).

Now let's create a table and write a query using a CTE (WITH ... AS, a named temporary result set that breaks complex logic into steps) and conditional aggregation SUM(CASE WHEN ...) to compute per-product metrics in one pass:

%%sql
-- Create a sample sales table and insert test rows
CREATE TABLE IF NOT EXISTS sales (
    sale_id INTEGER PRIMARY KEY,
    category TEXT, product TEXT, units INTEGER, revenue_usd REAL
);
INSERT OR REPLACE INTO sales VALUES
  (1, 'Q1', 'iPhone', 120, 96000), (2, 'Q1', 'iPad', 45, 27000),
  (3, 'Q2', 'iPhone', 150, 120000), (4, 'Q2', 'iPad', 60, 36000);

-- CTE calculates iPhone units and total revenue per quarter
WITH category_stats AS (
    SELECT
        category,
        SUM(CASE WHEN product = 'iPhone' THEN units ELSE 0 END)
            AS iphone_units,
        SUM(revenue_usd) AS total_revenue
    FROM sales
    GROUP BY category
)
SELECT category, iphone_units, total_revenue
FROM category_stats
ORDER BY total_revenue DESC;

The query reads cleanly from top to bottom, and you can send the result straight to a Pandas DataFrame by starting the cell with %%sql result_df << and calling result_df.head() in Python.

This convenience comes with two caveats. First, Colab sessions are temporary: restarting the runtime wipes local .db files and :memory: databases, so either mount Google Drive or keep your setup script at the top of the notebook. Second, SQLite has its own dialect: CTEs and window functions work, while dynamic typing and date functions differ from PostgreSQL and MySQL (for large CSV/Parquet files in Colab, DuckDB is another popular option).

What's Inside the Course and Who It Fits

The curriculum starts from scratch: sqlite3, the company_demo_data.db employee dataset, SQL magic, loading CSVs with Pandas, then SELECT, WHERE, ORDER BY, LIMIT, aggregates (COUNT, SUM, MIN, MAX), GROUP BY, CASE WHEN, and all JOIN types (INNER, LEFT, RIGHT, OUTER). Part two covers subqueries, CTEs, window functions, and CREATE INDEX.

The finale walks through five business problems. One asks for year-over-year (YoY) quarterly growth and the worst quarter — Q2 2016 at -23.34%. Instead of ORDER BY ... LIMIT 1, the query filters via a subquery so ties for the minimum aren't dropped. Details like that teach the core habit of analytical SQL: checking edge cases and breaking tasks into clear steps matters more than memorizing syntax.

The video has chapter markers, so if you already know the basics you can jump straight to JOINs, CTEs, or window functions. Basic Excel and Python familiarity is enough — just open Colab beside the video and type the queries yourself, or eight hours of passive watching will fade fast.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 4