“Keep showing up. That's where the magic happens.”
— GrindGram
View full list(413 problems)

Introduction to SQL· 27

Basics of SQL

  • What is SQL?
  • What is a query?
  • Query Definition
  • Why SQL Matters
  • Divider
  • Syntax in SQL
  • SQL Syntax Introduction
  • Advanced Note
  • SQL Introduction

Sample Database - College Management System

  • Table 4: enrollments
  • Scenario: Your College Database
  • Professors Table
  • Table 3: courses
  • Courses Table Description
  • Database Scenario
  • Divider
  • 4 Simple Tables
  • Table 1: students
  • Students Table Description
  • Students Table
  • Table 2: professors
  • Professors Table Description
  • Courses Table
  • Enrollments Table Description
  • Enrollments Table
  • Learning Quote

Basic SQL Queries· 87

Introduction to SQL Commands

  • Types of SQL Operations
  • SQL Types Introduction
  • SQL Categories
  • Learning Note

CREATE - Creating Tables

  • Constraint Note
  • CREATE Command
  • CREATE Introduction
  • CREATE Explanation
  • CREATE Requirements
  • CREATE Requirements List
  • Syntax Introduction
  • CREATE TABLE Syntax
  • Example Heading
  • Create Students Table
  • Divider
  • Adding Constraints
  • Constraints Explanation
  • CHECK Constraint
  • CHECK Constraint Example
  • Common Constraints
  • CREATE Table Quiz

INSERT - Adding Data

  • INSERT Command
  • INSERT Introduction
  • INSERT Requirements
  • INSERT Keywords
  • Basic Syntax
  • INSERT Syntax
  • Column Names Optional
  • Example
  • INSERT Students Example
  • INSERT Tips
  • INSERT Data Quiz

SELECT - Reading Data

  • SELECT Specific Columns
  • SELECT Command
  • Reading Data Introduction
  • SELECT Components
  • Syntax
  • SELECT Syntax
  • Example Introduction
  • SELECT All Explanation
  • SELECT All Example
  • Best Practice
  • SELECT Quiz

WHERE - Filtering Data

  • WHERE Clause
  • WHERE Introduction
  • What WHERE Does
  • WHERE Explanation
  • Syntax
  • WHERE Syntax
  • Common Operators
  • WHERE Operators
  • Divider
  • Examples
  • Example 1 Introduction
  • CSE Department Example
  • Example 2 Introduction
  • AND Operator Example
  • Example 3 Introduction
  • IN Operator Example
  • Example 4 Introduction
  • IS NULL Example
  • Example 5 Introduction
  • BETWEEN Operator Example
  • Example 6 Introduction
  • Complex Conditions Example
  • Parentheses Tip
  • WHERE Quiz 1
  • WHERE Quiz 2

DISTINCT - Removing Duplicates

  • Without DISTINCT
  • Result Without DISTINCT
  • With DISTINCT
  • Result With DISTINCT
  • Performance Tip
  • DISTINCT Quiz 1
  • Syntax
  • Comparison Introduction
  • DISTINCT
  • DISTINCT Introduction
  • DISTINCT Syntax
  • Example
  • DISTINCT Department
  • Divider
  • DISTINCT with Multiple Columns
  • Multiple Columns Explanation
  • DISTINCT Multiple Columns
  • Important Note
  • With vs Without DISTINCT

Grouping & Sorting· 75

ORDER BY - Sorting Results

  • ORDER BY
  • ORDER BY Introduction
  • Syntax
  • ORDER BY Syntax
  • Examples
  • Sort by CGPA
  • ORDER BY CGPA Example
  • Multiple Column Sort
  • Multiple Column Sort Example
  • ORDER BY Quiz

GROUP BY - Grouping Data

  • Divider
  • Core syntax
  • GROUP BY Syntax
  • Divider
  • Starter examples (our college DB)
  • Example 1 - Unique departments
  • Unique Departments
  • Example 2 - Finer buckets
  • Department + Year Grouping
  • Divider
  • DISTINCT vs GROUP BY (common doubt)
  • GROUP BY
  • Why GROUP BY?
  • Examples
  • Example Questions
  • Divider
  • What does "grouping rows" mean?
  • Grouping Explanation
  • Mini students table
  • Divider
  • Step-by-step mental model
  • Step 1 - Find the categories
  • Step 1 Details
  • Bucket Breakdown
  • NULL Values in GROUP BY
  • When to use what
  • DISTINCT Example
  • GROUP BY for Grouping
  • Divider
  • Rules you must remember (or you'll get errors)
  • Column Selection Rule
  • Correct Example
  • Incorrect Example
  • GROUP BY Quiz 1
  • GROUP BY Quiz 2

Aggregate Functions - Summarizing Data

  • Using with GROUP BY
  • Pro Tips
  • Aggregate Functions
  • What are Aggregate Functions?
  • Basic Example
  • Common Aggregate Functions
  • Function Reference
  • Employee Table Example
  • Department-wise Statistics
  • Aggregate Functions Quiz
  • GROUP BY Quiz

HAVING Clause - Filtering Groups

  • What Exactly Gets "Grouped"?
  • Combined WHERE and HAVING
  • HAVING Clause
  • What is the HAVING Clause?
  • Simple way to remember
  • Why We Need HAVING
  • WHERE Clause Limitation
  • ❌ Wrong Way - WHERE with Aggregate
  • ✅ Correct Way - HAVING
  • Grouping Explanation
  • Step-by-Step Execution
  • Execution Steps
  • Tiny Example
  • Key Takeaways
  • Key Takeaways List
  • Multiple Grouping Example
  • Combining WHERE and HAVING
  • HAVING Clause Quiz
  • WHERE vs HAVING Quiz

SQL Practice Queries· 18

  • Query 3 Description
  • Practice Queries
  • Introduction
  • Database Reference
  • Practice Query 1
  • Query 1 Description
  • Query 1 Solution
  • Practice Query 2
  • Query 2 Description
  • Query 2 Solution
  • Practice Query 3
  • Query 3 Solution
  • Practice Query 4
  • Query 4 Description
  • Query 4 Solution
  • Practice Tips
  • Practice Query Challenge
  • Aggregate Functions Quiz

SQL Constraints· 56

Introduction to Constraints

  • SET NULL Action
  • SQL Constraints
  • Types of Constraints
  • Constraint Types Overview
  • Introduction
  • Database Reference
  • Common CHECK Patterns
  • SET NULL Explanation
  • SET NULL Example
  • RESTRICT Action
  • RESTRICT Explanation
  • RESTRICT Example
  • CHECK Patterns Examples
  • Quiz: NOT NULL vs UNIQUE
  • Quiz: PRIMARY KEY
  • Quiz: FOREIGN KEY CASCADE
  • Quiz: CHECK Constraint
  • Quiz: DEFAULT Constraint
  • Quiz: Referential Integrity

NOT NULL and UNIQUE Constraints

  • NOT NULL Constraint
  • NOT NULL Explanation
  • UNIQUE Constraint
  • UNIQUE Notes
  • UNIQUE Explanation
  • Quiz: NOT NULL vs UNIQUE
  • NOT NULL Example
  • UNIQUE Example

PRIMARY KEY Constraints

  • PRIMARY KEY Explanation
  • PRIMARY KEY Example
  • PRIMARY KEY Rules
  • Quiz: PRIMARY KEY
  • PRIMARY KEY Constraint

FOREIGN KEY Constraints

  • FOREIGN KEY Constraint
  • FOREIGN KEY Definition
  • Quiz: FOREIGN KEY CASCADE
  • FOREIGN KEY Introduction
  • FOREIGN KEY Basic Example
  • Referential Actions
  • CASCADE Action
  • CASCADE Explanation
  • CASCADE Example

CHECK and DEFAULT Constraints

  • Quiz: CHECK and DEFAULT
  • CHECK Constraint
  • CHECK Explanation
  • CHECK Example
  • DEFAULT Constraint
  • DEFAULT Explanation
  • DEFAULT Example

Advanced Constraints & Best Practices

  • Quiz: Referential Integrity
  • Altering Constraints
  • Best Practices
  • Adding and Dropping Constraints
  • Altering Constraints Examples
  • Constraint Best Practices
  • Quick Recap
  • Recap

SQL JOINS· 88

Introduction to JOINS

  • SQL JOINS - Complete Guide
  • Types of JOINS
  • Why We Need JOINs
  • Example Scenario
  • JOIN Types Visual Guide
  • JOIN Types Comparison
  • What is a JOIN?

INNER JOIN

  • INNER JOIN
  • INNER JOIN Syntax
  • INNER JOIN Syntax Example
  • INNER JOIN Example
  • INNER JOIN Example Query
  • Important Note
  • Query Result
  • What is INNER JOIN?
  • Simple Explanation
  • How JOINs Work
  • Example Question
  • INNER JOIN Quiz

LEFT JOIN (LEFT OUTER JOIN)

  • What is LEFT JOIN?
  • How LEFT JOIN Works
  • Syntax
  • LEFT JOIN Syntax
  • Example 1: All Students, Including Those Not Enrolled
  • Example 1 Question
  • Example 1 Query
  • Example 1 Result
  • Result Explanation
  • Key Point
  • Example 2: Courses with Enrollment Count
  • Example 2 Question
  • Example 2 Query
  • Example 2 Result
  • LEFT JOIN Quiz

RIGHT JOIN (RIGHT OUTER JOIN)

  • Syntax
  • RIGHT JOIN Syntax
  • Example: All Courses, Even Without Enrollments
  • RIGHT JOIN Example Query
  • RIGHT JOIN Result
  • Pro Tip
  • Same Query Using LEFT JOIN
  • LEFT JOIN Alternative
  • RIGHT JOIN Quiz
  • RIGHT JOIN (RIGHT OUTER JOIN)
  • What is RIGHT JOIN?
  • RIGHT JOIN vs LEFT JOIN

FULL OUTER JOIN

  • FULL OUTER JOIN Result
  • Result Explanation
  • FULL OUTER JOIN Quiz
  • What is FULL OUTER JOIN?
  • How FULL OUTER JOIN Works
  • Simple Explanation
  • Syntax
  • FULL OUTER JOIN Syntax
  • Example: All Students + All Courses
  • Example Goal
  • FULL OUTER JOIN Example Query
  • FULL OUTER JOIN

CROSS JOIN

  • What is CROSS JOIN?
  • Simple Explanation
  • Cartesian Join
  • Syntax
  • CROSS JOIN Syntax
  • CROSS JOIN
  • Example: Every Professor × Every Course
  • Example Question
  • CROSS JOIN Example Query
  • CROSS JOIN Result
  • Result Explanation
  • Where is CROSS JOIN used?
  • Use Cases Introduction
  • CROSS JOIN Use Cases
  • Important Warning
  • CROSS JOIN Quiz

SELF JOIN

  • How SELF JOIN Works
  • Example 1: Professor Mentors
  • Example 1 Scenario
  • Example 2: Students in Same Department
  • SELF JOIN
  • What is SELF JOIN?
  • Simple Explanation
  • SELF JOIN Example 1 Query
  • Example 1 Result
  • Example 2 Question
  • SELF JOIN Example 2 Query
  • Example 2 Result
  • Key Points
  • SELF JOIN Quiz

SQL Set Operations· 33

Introduction to Set Operations

  • What Are Set Operations?
  • Mathematical Set Operations

UNION - Combine Unique Results

  • UNION - Combine All Results
  • How UNION Works
  • Example 1: All Student Names and Professor Names
  • Example 2: All Departments (Students + Professors)
  • Result
  • Syntax
  • Solution
  • Solution

UNION ALL - Combine All Results

  • Key Difference
  • UNION ALL - Combine All Results (Keep Duplicates)
  • Result
  • Example: All Departments (Including Duplicates)

INTERSECT - Common Elements

  • INTERSECT - Common Elements Only
  • Example: Students Who Are Also Teaching Assistants
  • Result
  • Example: Common Departments
  • Result
  • Solution
  • Solution

EXCEPT - Elements from First Set Only

  • EXCEPT (MINUS in Oracle) - Elements from First Set Only
  • Example: Students Not Teaching
  • Result
  • Example: Departments with Only Students (No Professors)
  • Result
  • Solution
  • Solution

Advanced Set Operations

  • Advanced Examples - Complex Analysis
  • Quick Comparison Table
  • Important Rules for Set Operations
  • Practice Exercises
  • Complex Analysis Query

SQL Subqueries· 29

Introduction to Subqueries

  • What's a Subquery?
  • Definition
  • General Syntax
  • How Subqueries Work
  • Common Clauses Where Subqueries Are Used
  • Real-World Example
  • Example Query
  • Explanation

Single-Row Subqueries

  • Example: Find students who joined after the first admission date
  • Single-Row Subquery

Multi-Row Subqueries

  • Multi-Row Subquery
  • Example: Find students who live in the same city as professors
  • Explanation

Correlated Subqueries

  • Correlated Subquery
  • Example: Find students whose CGPA is above the average CGPA of their department
  • Explanation

Subqueries in Different Clauses

  • Subquery in FROM Clause (Inline View)
  • Example: Find average CGPA per department and show only those above 8
  • Explanation
  • Subquery in SELECT Clause (Scalar Subquery)
  • Example: Show each student with total student count next to their name
  • Subquery with EXISTS
  • Example: Find students who have at least one enrollment
  • Explanation

Subqueries vs JOINs - Best Practices

  • Types of Subqueries
  • Subquery vs JOIN Comparison
  • Use Subquery when:
  • Use JOIN when:
  • Pro Tip