introduction to SQL

Filtering and Querying data

Lesson 2 - Filtering & Querying Data Theory + Practice | ShopDB - Indian E-commerce Dataset Before You Start Run setup.sql in pgAdmin to create and populate ShopDB. Verify you see 5 tables with the correct row counts. Then work through this file top to bottom. What you’ll learn in this lesson: Concept What it does DISTINCT Remove duplicate values from results IN / NOT IN Match against a list of values BETWEEN Filter within a range LIKE / ILIKE Pattern matching on text IS NULL / IS NOT NULL Handle missing values CASE WHEN Conditional logic inside a query Date functions Filter and extract parts of dates COALESCE Replace NULL with a fallback value All queries in this lesson run on ShopDB. The dataset has: ...

March 17, 2026 · 12 min · 2494 words · By codeverra
introduction to SQL

Group by and Aggregations

Lesson 3 - Aggregations & Grouping Theory + Practice | CricketDB + ShopDB Before You Start This lesson uses both databases you have already built: CricketDB - players, matches, performances (Lesson 2.1) ShopDB - customers, products, orders, order_items (Lesson 2.2) Run the setup_check.sql from this lesson folder to confirm both are ready. Each section tells you which database to connect to in pgAdmin. What you will learn in this lesson: ...

March 17, 2026 · 15 min · 3134 words · By codeverra
introduction to SQL

Indexes and Schema Design

Lesson 2.7 - Indexes, Constraints & Schema Design Theory + Practice | All Three Databases Before You Start This lesson uses all three databases. Each section tells you which one to connect to. Quick check - run this in each database before starting: -- In cricketdb: SELECT COUNT(*) FROM performances; -- expect 30 -- In shopdb: SELECT COUNT(*) FROM order_items; -- expect 30+ -- In streamdb: SELECT COUNT(*) FROM watch_history; -- expect 50 What you will learn: ...

March 17, 2026 · 22 min · 4563 words · By codeverra
introduction to SQL

Introduction to SQL and Databases

SQL Lecture 01 - Introduction to SQL & Databases PostgreSQL | Beginner Reference Sheet | Use this during class 🐘 Table of Contents What is a Database? Types of Databases What is SQL? How SQL Commands Are Grouped Creating a Table - Full Breakdown Data Types in PostgreSQL Constraints - Rules for Your Data Primary Key & Foreign Key Common SQL Commands with Examples What Happens When You Violate a Constraint? Practice Table & 10 Beginner Questions 1. What is a Database? A database is an organised collection of data stored so it can be easily accessed, managed, and updated. ...

March 17, 2026 · 15 min · 3192 words · By codeverra
introduction to SQL

Joins and Relationships

Lesson 4 - JOINs & Relationships Theory + Practice | ShopDB Before You Start This lesson uses ShopDB exclusively. Connect to shopdb in pgAdmin before running any query. Run this to confirm your data is ready: SELECT 'customers' AS t, COUNT(*) FROM customers UNION ALL SELECT 'products', COUNT(*) FROM products UNION ALL SELECT 'orders', COUNT(*) FROM orders UNION ALL SELECT 'order_items',COUNT(*) FROM order_items; -- Expected: 20, 25, 15, 30 What you will learn: ...

March 17, 2026 · 17 min · 3562 words · By codeverra
introduction to SQL

Joins and Relationships

Lesson 5 - Subqueries & CTEs Theory + Practice | StreamDB - Indian Streaming Platform Before You Start This lesson introduces StreamDB - a Hotstar-style streaming platform. Run setup.sql to create and populate StreamDB Verify you see 6 tables with the correct row counts Connect to streamdb in pgAdmin before running any query The StreamDB schema: users shows genres ┌────┬───────┬──────┐ ┌────┬────────┬──────────┐ ┌────┬──────────┐ │ id │ name │ plan │ │ id │ title │is_premium│ │ id │ name │ └────┴───────┴──────┘ └────┴────────┴──────────┘ └────┴──────────┘ │ │ │ │ │ show_genres │ │ │ ┌──────────────┘ ┌────────────┘ │ │ show_id | genre_id │ │ └──────────────────────────┘ (many-to-many) │ subscriptions watch_history ┌────┬─────────┬──────────────┐ ┌────┬─────────┬─────────┬─────────┐ │ id │ user_id │ plan │ │ id │ user_id │ show_id │ minutes │ │ │ │ started_on │ │ │ │ watched │ watched │ │ │ │ expires_on │ └────┴─────────┴─────────┴─────────┘ └────┴─────────┴──────────────┘ What you will learn: ...

March 17, 2026 · 17 min · 3549 words · By codeverra
introduction to SQL

Modifying data & Schema Changes

Lesson 6 - Modifying Data & Schema Changes Theory + Practice | ShopDB Before You Start This lesson uses ShopDB. Connect to shopdb in pgAdmin before running any query. Important: This lesson modifies real data. Some queries will permanently change your database. The section on transactions shows you how to do this safely - read Part 7 before running anything you are unsure about. Quick data check: SELECT 'customers' AS t, COUNT(*) FROM customers UNION ALL SELECT 'products', COUNT(*) FROM products UNION ALL SELECT 'orders', COUNT(*) FROM orders UNION ALL SELECT 'order_items', COUNT(*) FROM order_items; -- Expected: 20, 25, 15, 30 What you will learn: ...

March 17, 2026 · 17 min · 3563 words · By codeverra
introduction to SQL

SQL Practice on Cricket Dataset: 12 Questions with Solutions

## Pratice easy, medium and hard questions on cricket dataset. <!DOCTYPE html> SQL Practice: CricketDB - Codeverra Codeverra · SQL Practice SQL Practice Set CricketDB 12 questions on a cricket dataset - players, matches, and ball-by-ball performances. Easy to hard. Every question has a one-line approach, a clean solution, and alternatives where they exist. ...

March 17, 2026 · 13 min · 2580 words · By codeverra
introduction to SQL

SQL Practice on Shopping Dataset: SQL Questions with Solutions

## Practice SQL questions on the shopping dataset. <!DOCTYPE html> SQL Practice: ShopDB - Codeverra Codeverra · SQL Practice SQL Practice Set ShopDB 12 questions on an Indian e-commerce dataset - customers, products, orders, and line items. Easy to hard. Every question includes the business context, a one-line approach, a clean query, and alternatives where they exist. ...

March 17, 2026 · 13 min · 2603 words · By codeverra