This repository contains a structured set of SQL examples and practice problems organized by topic, designed to help you learn SQL from basic to advanced concepts. Each folder focuses on a specific topic and includes examples and relevant practice problems.
-
- Fundamental SQL commands: SELECT, INSERT, UPDATE, DELETE
- Basic clauses: WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
- 5 practice problems focused on basic queries
-
- Joins (INNER, LEFT, RIGHT, FULL OUTER, CROSS)
- Subqueries (EXISTS, IN, NOT IN, SCALAR SUBQUERY)
- Common Table Expressions (CTE)
- Window Functions
- Hierarchical Queries
- 16 practice problems covering joins and advanced select techniques
-
3_transactions_and_concurrency
- Transaction control (BEGIN, COMMIT, ROLLBACK)
- Row locking (FOR UPDATE)
- Concurrency control and isolation levels
-
- JSON Functions
- XML Handling
- ARRAY Functions
- String Functions and Regular Expressions
- 7 practice problems on string manipulation and special data types
-
- Stored Procedures
- Triggers
- Dynamic SQL
-
6_analytical_and_performance_features
- Query Optimization
- Materialized Views
- Partitioning
- 7 practice problems focused on subqueries and analytical functions
-
- PIVOT and UNPIVOT operations
- String Aggregation
- 15 practice problems on aggregation, sorting, and grouping
-
- Recursive Queries
- Geospatial Data Queries
- Graph Queries
All examples are derived from a comprehensive master query (master_query.sql) that demonstrates many SQL features in a single file. This master query serves as a reference for how different SQL features can be combined in complex queries.
SQL Interview Cheatsheet — A comprehensive 2-hour final day revision guide covering:
- Window Functions (ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD)
- PARTITION BY patterns
- Common Table Expressions (CTEs)
- All types of JOINs with solutions
- Subqueries (IN, EXISTS, correlated)
- Aggregations & Grouping
- Theoretical interview questions with answers
- Quick reference patterns for common problems
- Start with folder 1 and work your way through in numerical order
- Each folder contains:
- A README.md file explaining the topic and listing relevant problems
- An SQL file with examples of the topic's features
- (In some folders) Problem descriptions and solutions
- Study the example file in each folder to understand the concepts
- Work through the practice problems to reinforce your learning
- Refer back to the master query to see how different features can be combined
The examples include syntax variations for different database systems where appropriate:
- MySQL/MariaDB
- PostgreSQL
- Oracle
- SQL Server
Note that not all features are available in all database systems, and syntax may vary.
This repository is designed to take you from basic SQL queries to advanced database concepts. By working through the folders in order, you'll build a solid foundation in SQL and gradually tackle more complex topics.
Happy learning! # sql