Free demoJob-oriented courses at Debugshala, Old Palasia, Indore. Freshers, non-IT and year-gap welcome.Book a free demo +91-8982385539
Free course · by Debugshala, Indore

SQL Tutorial

29 free lessons, in the order we teach them in class: start at lesson 1 and work down. Every lesson has an analogy, a diagram, code you can run or copy, a quick quiz and an FAQ.

  • 29Lessons
  • 4Modules
  • ~5 hReading time
  • FreeAlways

01SQL Basics

  1. What is SQL? Databases, Tables and RDBMS Explained SimplyWhat is SQL? Learn how relational databases store tables, what an RDBMS does, and run your first real SQL query in Python with zero setup needed.
  2. SQL Data Types: INT, DECIMAL, VARCHAR and DATE ExplainedSQL data types explained: integers, DECIMAL for money, VARCHAR, DATE and BOOLEAN, with MySQL, PostgreSQL and SQLite differences you can run.
  3. SQL CREATE TABLE and ALTER TABLE: Syntax with ExamplesLearn SQL CREATE TABLE and ALTER TABLE with runnable examples: columns, constraints, foreign keys, adding and renaming columns, and SQLite limits.
  4. SQL INSERT, UPDATE and DELETE: Add and Change Data SafelySQL INSERT, UPDATE and DELETE explained with runnable examples, a safe transaction routine, upserts, and the missing WHERE mistake to avoid.
  5. SQL SELECT and WHERE: Filter Rows with Clear ExamplesMaster SQL SELECT and WHERE: comparison operators, AND/OR precedence, IN, BETWEEN, LIKE and IS NULL, with runnable examples on a retail database.
  6. SQL ORDER BY, LIMIT and DISTINCT: Sort and Trim ResultsLearn SQL ORDER BY, LIMIT, OFFSET and DISTINCT with runnable examples: multi-column sorts, NULL ordering, top-N lists and page-by-page results.
  7. SQL for Data Analysis: SELECT, GROUP BY and JOIN with ExamplesLearn SQL for data analysis with runnable examples: SELECT, WHERE, ORDER BY, GROUP BY, HAVING and JOIN, plus the query order that explains common errors.

02SQL Queries

  1. SQL Aggregate Functions: COUNT, SUM, AVG, MIN and MAXSQL aggregate functions explained: COUNT(*) vs COUNT(column), SUM, AVG, MIN and MAX, how NULLs change results, and conditional totals you can run.
  2. SQL GROUP BY and HAVING: Group, Summarise and Filter TotalsLearn SQL GROUP BY and HAVING with runnable examples: totals per store, multi-column groups, WHERE vs HAVING, and the ungrouped column trap.
  3. SQL Joins Explained: INNER, LEFT, RIGHT and FULL OUTER JOINSQL joins explained with runnable examples: INNER, LEFT, RIGHT and FULL OUTER JOIN, anti-joins, three-table joins and the ON vs WHERE filter trap.
  4. SQL Self Join and Cross Join: Examples, Uses and PitfallsLearn SQL self join and cross join with runnable examples: employee-manager lists, comparing rows, and complete report grids with zeros filled in.
  5. SQL UNION, INTERSECT and EXCEPT: Combine Query ResultsSQL UNION vs UNION ALL, INTERSECT and EXCEPT explained with runnable examples, column rules, MySQL and SQLite support, and grand total rows.
  6. SQL Subqueries: Scalar, IN, EXISTS and Correlated ExamplesLearn SQL subqueries with runnable examples: scalar values, IN lists, EXISTS, correlated subqueries, derived tables and the NOT IN NULL trap.
  7. SQL CTE (WITH Clause): Common Table Expressions ExplainedSQL CTEs explained: WITH clause syntax, chaining multiple CTEs, CTE vs subquery vs view, and recursive CTEs for date ranges and hierarchies.
  8. SQL Window Functions: ROW_NUMBER, RANK, LAG, Running TotalsSQL window functions explained with runnable examples: OVER and PARTITION BY, ROW_NUMBER vs RANK, top N per group, running totals and LAG/LEAD.
  9. SQL CASE WHEN: Conditional Logic in Queries with ExamplesLearn SQL CASE WHEN with runnable examples: searched and simple CASE, labelling rows, pivoting with SUM(CASE), custom sorting and the NULL trap.
  10. Handling NULL in SQL: IS NULL, COALESCE, NULLIF ExplainedHandle NULL in SQL with confidence: three-valued logic, IS NULL, COALESCE vs IFNULL, NULLIF for divide by zero, and how aggregates skip NULLs.
  11. SQL String Functions: TRIM, SUBSTR, REPLACE, CONCAT and MoreSQL string functions with runnable examples: clean names and phone numbers with TRIM, REPLACE and SUBSTR, join text, and SQLite vs MySQL names.
  12. SQL Date Functions: strftime, DATEDIFF and Date ArithmeticSQL date and time functions explained: extract weekdays, add days, find date gaps, group by week or month, and avoid BETWEEN and UTC-vs-IST bugs.

03Database Design

  1. SQL Constraints: Primary Key, Foreign Key, UNIQUE and CHECKSQL constraints explained with runnable examples: primary and foreign keys, composite keys, UNIQUE, CHECK, NOT NULL and ON DELETE CASCADE options.
  2. Database Normalization: 1NF, 2NF and 3NF Explained SimplyDatabase normalization explained with a real bill sheet: update, insert and delete anomalies, 1NF, 2NF and 3NF step by step, and when to denormalize.
  3. SQL Indexes Explained: How an Index Speeds Up Your QueriesLearn how SQL indexes work: B-trees, CREATE INDEX, reading EXPLAIN plans, composite indexes and the leftmost prefix rule, and when not to index.
  4. SQL Views: How to Create, Use and Update Views with ExamplesLearn SQL views with runnable examples: CREATE VIEW, views for security and reuse, updatable views, WITH CHECK OPTION and materialized views compared.
  5. SQL Transactions and ACID Properties Explained with ExamplesSQL transactions explained with runnable code: BEGIN, COMMIT, ROLLBACK, savepoints, the four ACID properties and isolation levels in MySQL and PostgreSQL.
  6. SQL Stored Procedures and Functions in MySQL and PostgreSQLWrite SQL stored procedures and functions in MySQL and PostgreSQL: IN and OUT parameters, error handling, procedure vs function, and SQLite alternatives.
  7. SQL Triggers Explained: BEFORE, AFTER and INSTEAD OF ExamplesLearn SQL triggers with runnable SQLite examples: AFTER INSERT stock updates, audit logs with OLD and NEW, BEFORE checks and INSTEAD OF triggers on views.
  8. SQL Query Optimization: Practical Ways to Speed Up Slow QueriesSpeed up slow SQL queries: read EXPLAIN plans, write sargable filters, replace correlated subqueries, fix N+1 queries and use keyset pagination, with timings.

04SQL Career

  1. SQL Practice Problems with Solutions: 15 Graded ExercisesSolve 15 graded SQL practice problems with worked solutions on one retail dataset: joins, GROUP BY, HAVING, window functions and data-quality checks.
  2. SQL Interview Questions and Answers for Freshers and Experienced15 SQL interview questions with model answers and runnable code: WHERE vs HAVING, joins, RANK vs DENSE_RANK, Nth highest, duplicates, ACID and indexes.
Practise on Debugshala TestOnline compiler, coding questions, aptitude and reasoning MCQs. Free at test.debugshala.com ↗