Structured Query Language

SQL — Complete Tutorial

Learn SQL from absolute zero. Every topic explained simply with real examples you can edit and practice quickly.

🟩 Beginner Friendly ▶ Live Code Editor 📚 76 Topics
Your Progress3% complete
Live SQL Lab

Edit the SQL below and click Run. Queries execute on a small in-memory SQLite database with sample data.

sql-lab.sql
📝 Edit Code
👁 Output
💡 Try adding a WHERE filter (ex: country = 'India') and run again.
∙ Chapter 001

SQL Tutorial

Learn SQL Tutorial with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-tutorial.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Hello SQL' AS message;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 002

SQL HOME

Learn SQL HOME with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-home.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Hello SQL' AS message;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 003

SQL Intro

Learn SQL Intro with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-intro.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Hello SQL' AS message;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 004

SQL Syntax

Learn SQL Syntax with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-syntax.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, citySelects columns/expressions.
FROM customersChooses the source table(s).
WHERE country = 'India'Filters rows before grouping.
ORDER BY customer_name ASC;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 005

SQL Select

Learn SQL Select with a small query you can edit and run.

📝Syntax
SELECT columns
FROM table
WHERE condition
ORDER BY column DESC
LIMIT 10;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-select.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, countrySelects columns/expressions.
FROM customers;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 006

SQL Select Distinct

Learn SQL Select Distinct with a small query you can edit and run.

📝Syntax
SELECT columns
FROM table
WHERE condition
ORDER BY column DESC
LIMIT 10;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-select-distinct.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT DISTINCT countrySelects columns/expressions.
FROM customers;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 007

SQL Where

Learn SQL Where with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-where.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amountSelects columns/expressions.
FROM ordersChooses the source table(s).
WHERE total_amount > 500Filters rows before grouping.
ORDER BY total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 008

SQL Order By

Learn SQL Order By with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-order-by.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, citySelects columns/expressions.
FROM customersChooses the source table(s).
ORDER BY city ASC, customer_name ASC;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 009

SQL And

Learn SQL And with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-and.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_nameSelects columns/expressions.
FROM customersChooses the source table(s).
WHERE country = 'India' AND city = 'Mumbai';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 010

SQL Or

Learn SQL Or with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-or.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_nameSelects columns/expressions.
FROM customersChooses the source table(s).
WHERE country = 'USA' OR country = 'UK';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 011

SQL Not

Learn SQL Not with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-not.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, countrySelects columns/expressions.
FROM customersChooses the source table(s).
WHERE NOT country = 'India';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 012

SQL Insert Into

Learn SQL Insert Into with a small query you can edit and run.

📝Syntax
INSERT INTO table (col1, col2)
VALUES (val1, val2);
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-insert-into.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
INSERT INTO customers (customer_name, city, country)Inserts new row(s).
VALUES ('Zara', 'Dubai', 'UAE');SQL statement line.
SELECT customer_name, countrySelects columns/expressions.
FROM customersChooses the source table(s).
ORDER BY id DESCSorts the result set.
LIMIT 3;Limits how many rows are returned.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 013

SQL Null Values

Learn SQL Null Values with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-null-values.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, citySelects columns/expressions.
FROM customersChooses the source table(s).
WHERE city IS NULL;Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 014

SQL Update

Learn SQL Update with a small query you can edit and run.

📝Syntax
UPDATE table
SET col = value
WHERE condition;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-update.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
UPDATE customersUpdates existing row(s).
SET city = 'Pune'SQL statement line.
WHERE customer_name = 'Aarav';Filters rows before grouping.
SELECT customer_name, citySelects columns/expressions.
FROM customersChooses the source table(s).
WHERE customer_name = 'Aarav';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 015

SQL Delete

Learn SQL Delete with a small query you can edit and run.

📝Syntax
DELETE FROM table
WHERE condition;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-delete.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
INSERT INTO customers (customer_name, city, country)Inserts new row(s).
VALUES ('Temp', 'Nowhere', 'NA');SQL statement line.
DELETE FROM customers WHERE customer_name = 'Temp';Deletes row(s).
SELECT COUNT(*) AS customersSelects columns/expressions.
FROM customers;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 016

SQL Select Top

Learn SQL Select Top with a small query you can edit and run.

📝Syntax
SELECT columns
FROM table
WHERE condition
ORDER BY column DESC
LIMIT 10;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-select-top.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amountSelects columns/expressions.
FROM ordersChooses the source table(s).
ORDER BY total_amount DESCSorts the result set.
LIMIT 2;Limits how many rows are returned.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 017

SQL Aggregate Functions

Learn SQL Aggregate Functions with a small query you can edit and run.

📝Syntax
SELECT col, COUNT(*)
FROM table
GROUP BY col
HAVING COUNT(*) > 1;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-aggregate-functions.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Counts, totals, and averages for KPIs.
  • 2Finding top customers/products by revenue.
Common Mistakes
  • 1Mixing non-aggregated columns without GROUP BY.
  • 2Using WHERE instead of HAVING for aggregate filters.
Best Practices
  • 1Group first, then filter aggregates with HAVING.
  • 2Name aggregates with aliases (AS total_sales).
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 018

SQL Min()

Learn SQL Min() with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-min.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 019

SQL Max()

Learn SQL Max() with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-max.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 020

SQL Count()

Learn SQL Count() with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-count.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 021

SQL Sum()

Learn SQL Sum() with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-sum.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 022

SQL Avg()

Learn SQL Avg() with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-avg.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECTSQL statement line.
COUNT(*) AS order_count,SQL statement line.
MIN(total_amount) AS min_total,SQL statement line.
MAX(total_amount) AS max_total,SQL statement line.
SUM(total_amount) AS sum_total,SQL statement line.
AVG(total_amount) AS avg_totalSQL statement line.
FROM orders;Chooses the source table(s).
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 023

SQL Like

Learn SQL Like with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-like.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_nameSelects columns/expressions.
FROM customersChooses the source table(s).
WHERE customer_name LIKE 'M%';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 024

SQL Wildcards

Learn SQL Wildcards with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-wildcards.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_nameSelects columns/expressions.
FROM customersChooses the source table(s).
WHERE customer_name LIKE '_ia';Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 025

SQL In

Learn SQL In with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-in.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, countrySelects columns/expressions.
FROM customersChooses the source table(s).
WHERE country IN ('India', 'USA');Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 026

SQL Between

Learn SQL Between with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-between.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amountSelects columns/expressions.
FROM ordersChooses the source table(s).
WHERE total_amount BETWEEN 100 AND 1000Filters rows before grouping.
ORDER BY total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 027

SQL Aliases

Learn SQL Aliases with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-aliases.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name AS name, country AS cSelects columns/expressions.
FROM customersChooses the source table(s).
ORDER BY name;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 028

SQL Joins

Learn SQL Joins with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-joins.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 029

SQL Inner Join

Learn SQL Inner Join with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-inner-join.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 030

SQL Left Join

Learn SQL Left Join with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-left-join.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 031

SQL Right Join

Learn SQL Right Join with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-right-join.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 032

SQL Full Join

Learn SQL Full Join with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-full-join.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 033

SQL Self Join

Learn SQL Self Join with a small query you can edit and run.

📝Syntax
SELECT a.col, b.col
FROM a
JOIN b ON b.a_id = a.id;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-self-join.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT o.id AS order_id, c.customer_name, o.total_amountSelects columns/expressions.
FROM orders oChooses the source table(s).
JOIN customers c ON c.id = o.customer_idCombines rows from related tables.
ORDER BY o.total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Combine customer + order data for reports.
  • 2Enrich rows by joining lookup tables (products, departments).
Common Mistakes
  • 1Joining on the wrong key and duplicating rows.
  • 2Using SELECT * with joins and getting ambiguous columns.
Best Practices
  • 1Always join on the correct primary/foreign key.
  • 2Alias tables (`c`, `o`) and select only needed columns.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 034

SQL Union

Learn SQL Union with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-union.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT country AS label FROM customersSelects columns/expressions.
UNIONSQL statement line.
SELECT department AS label FROM employees;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 035

SQL Union All

Learn SQL Union All with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-union-all.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT country AS label FROM customersSelects columns/expressions.
UNIONSQL statement line.
SELECT department AS label FROM employees;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 036

SQL Group By

Learn SQL Group By with a small query you can edit and run.

📝Syntax
SELECT col, COUNT(*)
FROM table
GROUP BY col
HAVING COUNT(*) > 1;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-group-by.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT country, COUNT(*) AS customersSelects columns/expressions.
FROM customersChooses the source table(s).
GROUP BY countryGroups rows for aggregation.
ORDER BY customers DESC;Sorts the result set.
🏢Real-world
  • 1Counts, totals, and averages for KPIs.
  • 2Finding top customers/products by revenue.
Common Mistakes
  • 1Mixing non-aggregated columns without GROUP BY.
  • 2Using WHERE instead of HAVING for aggregate filters.
Best Practices
  • 1Group first, then filter aggregates with HAVING.
  • 2Name aggregates with aliases (AS total_sales).
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 037

SQL Having

Learn SQL Having with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-having.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_id, COUNT(*) AS ordersSelects columns/expressions.
FROM ordersChooses the source table(s).
GROUP BY customer_idGroups rows for aggregation.
HAVING COUNT(*) >= 2;Filters groups after aggregation.
🏢Real-world
  • 1Counts, totals, and averages for KPIs.
  • 2Finding top customers/products by revenue.
Common Mistakes
  • 1Mixing non-aggregated columns without GROUP BY.
  • 2Using WHERE instead of HAVING for aggregate filters.
Best Practices
  • 1Group first, then filter aggregates with HAVING.
  • 2Name aggregates with aliases (AS total_sales).
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 038

SQL Exists

Learn SQL Exists with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-exists.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_nameSelects columns/expressions.
FROM customers cChooses the source table(s).
WHERE EXISTS (Filters rows before grouping.
SELECT 1 FROM orders o WHERE o.customer_id = c.idSelects columns/expressions.
);SQL statement line.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 039

SQL Any

Learn SQL Any with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-any.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amountSelects columns/expressions.
FROM ordersChooses the source table(s).
WHERE total_amount > (SELECT AVG(total_amount) FROM orders);Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 040

SQL All

Learn SQL All with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-all.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amountSelects columns/expressions.
FROM ordersChooses the source table(s).
WHERE total_amount > (SELECT AVG(total_amount) FROM orders);Filters rows before grouping.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 041

SQL Select Into

Learn SQL Select Into with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-select-into.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE high_value_orders ASCreates a database object (table/view/index).
SELECT * FROM orders WHERE total_amount > 500;Selects columns/expressions.
SELECT COUNT(*) AS rows_in_new_table FROM high_value_orders;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 042

SQL Insert Into Select

Learn SQL Insert Into Select with a small query you can edit and run.

📝Syntax
INSERT INTO table (col1, col2)
VALUES (val1, val2);
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-insert-into-select.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
INSERT INTO customers (customer_name, city, country)Inserts new row(s).
VALUES ('Zara', 'Dubai', 'UAE');SQL statement line.
SELECT customer_name, countrySelects columns/expressions.
FROM customersChooses the source table(s).
ORDER BY id DESCSorts the result set.
LIMIT 3;Limits how many rows are returned.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 043

SQL Case

Learn SQL Case with a small query you can edit and run.

📝Syntax
SELECT col,
  CASE WHEN col > 0 THEN 'pos' ELSE 'non-pos' END AS label
FROM table;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-case.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, total_amount,Selects columns/expressions.
CASESQL statement line.
WHEN total_amount >= 1000 THEN 'high'SQL statement line.
WHEN total_amount >= 200 THEN 'medium'SQL statement line.
ELSE 'low'SQL statement line.
END AS bucketSQL statement line.
FROM ordersChooses the source table(s).
ORDER BY total_amount DESC;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 044

SQL Null Functions

Learn SQL Null Functions with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-null-functions.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, COALESCE(city, 'Unknown') AS citySelects columns/expressions.
FROM customersChooses the source table(s).
ORDER BY customer_name;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 045

SQL Stored Procedures

Learn SQL Stored Procedures with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-stored-procedures.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Stored procedures demo (read note)' AS info;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 046

SQL Comments

Learn SQL Comments with a small query you can edit and run.

📝Syntax
-- single line
/* multi line */
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-comments.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
/* Multi-lineSQL statement line.
comment */SQL statement line.
SELECT 1 AS one;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 047

SQL Operators

Learn SQL Operators with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-operators.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 7 + 3 AS add, 7 * 3 AS mul, 7 > 3 AS is_greater;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
SQL Database
∙ Chapter 048

SQL Database

Learn SQL Database with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-database.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 1 AS example;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 049

SQL Create DB

Learn SQL Create DB with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-create-db.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Read the explanation for this topic.' AS note;Selects columns/expressions.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 050

SQL Drop DB

Learn SQL Drop DB with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-drop-db.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Read the explanation for this topic.' AS note;Selects columns/expressions.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 051

SQL Backup DB

Learn SQL Backup DB with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-backup-db.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Read the explanation for this topic.' AS note;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 052

SQL Create Table

Learn SQL Create Table with a small query you can edit and run.

📝Syntax
CREATE TABLE table (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL
);
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-create-table.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE students (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
marks INTEGERSQL statement line.
);SQL statement line.
INSERT INTO students (name, marks) VALUES ('Mia', 88), ('Noah', 72);Inserts new row(s).
SELECT * FROM students;Selects columns/expressions.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 053

SQL Drop Table

Learn SQL Drop Table with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-drop-table.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE tmp_table (id INTEGER);Creates a database object (table/view/index).
DROP TABLE tmp_table;Removes a database object.
SELECT 'dropped tmp_table' AS status;Selects columns/expressions.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 054

SQL Alter Table

Learn SQL Alter Table with a small query you can edit and run.

📝Syntax
ALTER TABLE table ADD COLUMN new_col TEXT;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-alter-table.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo (id INTEGER);Creates a database object (table/view/index).
ALTER TABLE demo ADD COLUMN name TEXT;Changes a table definition.
PRAGMA table_info(demo);SQL statement line.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 055

SQL Constraints

Learn SQL Constraints with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-constraints.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Design tables with correct keys and constraints.
  • 2Evolve schema with migrations.
Common Mistakes
  • 1Changing schema directly in production without a migration plan.
  • 2Missing indexes on lookup/join columns.
Best Practices
  • 1Use migrations + backups.
  • 2Add constraints to enforce data integrity.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 056

SQL Not Null

Learn SQL Not Null with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-not-null.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 057

SQL Unique

Learn SQL Unique with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-unique.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 058

SQL Primary Key

Learn SQL Primary Key with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-primary-key.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 059

SQL Foreign Key

Learn SQL Foreign Key with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-foreign-key.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 060

SQL Check

Learn SQL Check with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-check.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 061

SQL Default

Learn SQL Default with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-default.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_users (Creates a database object (table/view/index).
id INTEGER PRIMARY KEY AUTOINCREMENT,SQL statement line.
name TEXT NOT NULL,SQL statement line.
role TEXT NOT NULL DEFAULT 'user'SQL statement line.
);SQL statement line.
INSERT INTO demo_users (name) VALUES ('Aarav');Inserts new row(s).
SELECT * FROM demo_users;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 062

SQL Index

Learn SQL Index with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-index.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE INDEX idx_orders_total ON orders(total_amount);Creates a database object (table/view/index).
SELECT name, sql FROM sqlite_master WHERE type = 'index';Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 063

SQL Auto Increment

Learn SQL Auto Increment with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-auto-increment.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE TABLE demo_ai (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);Creates a database object (table/view/index).
INSERT INTO demo_ai (name) VALUES ('one'), ('two');Inserts new row(s).
SELECT * FROM demo_ai;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 064

SQL Dates

Learn SQL Dates with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-dates.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT id, created_atSelects columns/expressions.
FROM ordersChooses the source table(s).
WHERE created_at >= '2026-02-01'Filters rows before grouping.
ORDER BY created_at;Sorts the result set.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 065

SQL Views

Learn SQL Views with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-views.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
CREATE VIEW v_order_totals ASCreates a database object (table/view/index).
SELECT id, total_amount FROM orders;Selects columns/expressions.
SELECT * FROM v_order_totals ORDER BY total_amount DESC;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 066

SQL Injection

Learn SQL Injection with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-injection.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Use prepared statements (see notes)' AS info;Selects columns/expressions.
🏢Real-world
  • 1Secure logins/search endpoints using parameterized queries.
  • 2Prevent SQL injection attacks.
Common Mistakes
  • 1String concatenation with user input.
  • 2Logging full SQL with secrets.
Best Practices
  • 1Always use prepared statements / parameters in app code.
  • 2Validate and limit inputs.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 067

SQL Parameters

Learn SQL Parameters with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-parameters.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name FROM customers WHERE country = 'India';Selects columns/expressions.
🏢Real-world
  • 1Secure logins/search endpoints using parameterized queries.
  • 2Prevent SQL injection attacks.
Common Mistakes
  • 1String concatenation with user input.
  • 2Logging full SQL with secrets.
Best Practices
  • 1Always use prepared statements / parameters in app code.
  • 2Validate and limit inputs.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 068

SQL Prepared Statements

Learn SQL Prepared Statements with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-prepared-statements.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name FROM customers WHERE country = 'India';Selects columns/expressions.
🏢Real-world
  • 1Secure logins/search endpoints using parameterized queries.
  • 2Prevent SQL injection attacks.
Common Mistakes
  • 1String concatenation with user input.
  • 2Logging full SQL with secrets.
Best Practices
  • 1Always use prepared statements / parameters in app code.
  • 2Validate and limit inputs.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 069

SQL Hosting

Learn SQL Hosting with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-hosting.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT 'Read the explanation for this topic.' AS note;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
SQL References
∙ Chapter 070

SQL References

Learn SQL References with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-references.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 071

SQL Data Types

Learn SQL Data Types with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-data-types.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 072

SQL Keywords

Learn SQL Keywords with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-keywords.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 073

MySQL Functions

Learn MySQL Functions with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

mysql-functions.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 074

SQL Server Functions

Learn SQL Server Functions with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-server-functions.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 075

MS Access Functions

Learn MS Access Functions with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

ms-access-functions.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
∙ Chapter 076

SQL Quick Ref

Learn SQL Quick Ref with a small query you can edit and run.

📝Syntax
statement;
Example (Edit & Run)

Edit the SQL below and click Run. The output panel shows a table (for SELECT) or rows affected (for other statements).

sql-quick-ref.sql
📝 Edit Code
👁 Output
💡 Tip: start with SELECT *, then narrow the columns and add filters.
🔍Line-by-line
LineMeaning
SELECT customer_name, country FROM customers ORDER BY customer_name LIMIT 5;Selects columns/expressions.
🏢Real-world
  • 1Reporting dashboards, analytics, and backend APIs read data with SQL.
Common Mistakes
  • 1Forgetting a WHERE clause in UPDATE/DELETE.
Best Practices
  • 1Start with SELECT * then narrow columns + filters.
📖Summary & Practice
  • 1Practice the query on sample data, then apply the same pattern to real tables.
  • 2Read query output carefully and verify counts when joining/grouping.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one clause (WHERE/JOIN/GROUP BY) and predict the row count.
  • 2Add a new column to SELECT and rename it with AS.
  • 3Write the same query in a slightly different way and compare results.
PreviousBack to Home
🎉 SQL Tutorial Complete (76 topics)!
Next UpJava Basics →