Skip to content

About

My solutions to SQL exercises (SQLBolt, LeetCode SQL 50, DataLemur) with notes on each approach

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SQL Practice

My solutions to SQL exercises, written while learning SQL for data analytics and engineering. Each file includes the problem link, the table schema, and short notes on my approach.

Progress

Source Solved
SQLBolt ✅ 18 / 18
Select Star SQL ✅ Completed — notes
LeetCode Top SQL 50 15 / 50
DataLemur 0

Topics covered

  • Filtering: WHERE, BETWEEN, IN, LIKE with % / _ wildcards
  • Sorting & pagination: ORDER BY, LIMIT, OFFSET, DISTINCT
  • Joins: INNER, LEFT, CROSS and self-joins; anti-join pattern (LEFT JOIN ... WHERE key IS NULL)
  • NULL handling: IS NULL, COALESCE, why NULL != x is never TRUE, COUNT(*) vs COUNT(column)
  • Aggregation: COUNT, SUM, AVG, MAX, GROUP BY, HAVING vs WHERE
  • Conditional aggregation: AVG(CASE WHEN ... THEN 1 ELSE 0 END) for rates
  • Expressions & functions: computed columns, aliases, integer vs decimal division, ROUND, DATEDIFF, CHAR_LENGTH vs LENGTH
  • Query execution order: why SELECT aliases work in ORDER BY but not in WHERE
  • Modifying data: INSERT, UPDATE, DELETE (verify the WHERE with a SELECT first)
  • Schema: CREATE TABLE, ALTER TABLE, DROP TABLE, primary & foreign keys

LeetCode Top SQL 50

# Problem Difficulty Key concept
1757 Recyclable and Low Fat Products Easy Filtering with AND
584 Find Customer Referee Easy NULL in comparisons
595 Big Countries Easy OR conditions
1148 Article Views I Easy DISTINCT, aliases
1683 Invalid Tweets Easy CHAR_LENGTH vs LENGTH (UTF-8)
1378 Replace Employee ID With The Unique Identifier Easy LEFT JOIN
1068 Product Sales Analysis I Easy INNER JOIN on a foreign key
1581 Customer Who Visited but Did Not Make Any Transactions Easy Anti-join + GROUP BY
197 Rising Temperature Easy Self-join, DATEDIFF
1661 Average Time of Process per Machine Easy Self-join on a composite key
577 Employee Bonus Easy LEFT JOIN + NULL filter
1280 Students and Examinations Easy CROSS JOIN, COUNT(column)
570 Managers with at Least 5 Direct Reports Medium Self-join + HAVING
1934 Confirmation Rate Medium Conditional aggregation
620 Not Boring Movies Easy Filtering, %

SQLBolt solutions

# Lesson Key concept
01 SELECT queries Selecting columns
02 Queries with constraints (Pt. 1) WHERE, BETWEEN
03 Queries with constraints (Pt. 2) LIKE, wildcards
04 Filtering & sorting DISTINCT, ORDER BY, LIMIT
05 Simple SELECT review Combining clauses
06 JOINs INNER JOIN
07 OUTER JOINs LEFT JOIN
08 NULLs IS NULL, anti-join
09 Expressions Computed columns, aliases
10 Aggregates (Pt. 1) GROUP BY
11 Aggregates (Pt. 2) HAVING vs WHERE
12 Order of execution Logical query order
13 Inserting rows INSERT, primary keys
14 Updating rows UPDATE, escaping quotes
15 Deleting rows DELETE, orphan rows
16 Creating tables CREATE TABLE, constraints
17 Altering tables ALTER TABLE, defaults
18 Dropping tables DROP TABLE

Notes

  • SQLBolt runs on SQLite and LeetCode on MySQL, so some solutions include comments on where standard SQL (e.g. PostgreSQL) behaves differently.
  • String literals use single quotes; columns are table-qualified in multi-table queries.

About

My solutions to SQL exercises (SQLBolt, LeetCode SQL 50, DataLemur) with notes on each approach

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors