This repository, SQL_Notes, is a well-organized collection of SQL problem solutions that primarily includes LeetCode SQL challenges alongside problems from other sources. It aims to be more than just a collection of answers; it also provides explanations and reminders of key SQL concepts, useful for both learning and refreshing your knowledge.
This repository will cover many important concepts, including:
- Basic SQL Syntax:
SELECT
,FROM
,WHERE
,ORDER BY
,GROUP BY
,HAVING
- Filtering Data:
WHERE
clause, comparison operators, logical operators (AND
,OR
,NOT
),IN
,BETWEEN
,LIKE
- Joining Tables:
INNER JOIN
,LEFT JOIN
,RIGHT JOIN
,FULL OUTER JOIN
,CROSS JOIN
, self-joins - Aggregate Functions:
COUNT
,SUM
,AVG
,MIN
,MAX
- Grouping Data:
GROUP BY
clause,HAVING
clause - Subqueries: Using subqueries in
SELECT
,FROM
,WHERE
, andHAVING
clauses - Window Functions:
OVER
,PARTITION BY
,ORDER BY
withinPARTITION
,RANK
,DENSE_RANK
,ROW_NUMBER
- Common Table Expressions (CTEs):
WITH
clause - Data Manipulation:
INSERT
,UPDATE
,DELETE
- Data Definition:
CREATE TABLE
,ALTER TABLE
,DROP TABLE
, data types, constraints (PRIMARY KEY
,FOREIGN KEY
,UNIQUE
,NOT NULL
) - Indexes: Creating and using indexes to improve query performance
- Transactions: ACID properties,
BEGIN TRANSACTION
,COMMIT
,ROLLBACK
- String Functions:
SUBSTRING
,CONCAT
,LENGTH
,TRIM
,UPPER
,LOWER
- Date and Time Functions: Functions specific to your database system (e.g., MySQL's
DATE()
,YEAR()
,MONTH()
,DAY()
,DATE_FORMAT()
; PostgreSQL'sdate_part()
,to_char()
) - Conditional Logic:
CASE
statements - NULL Handling:
IS NULL
,IS NOT NULL
,COALESCE
- Set Operations:
UNION
,UNION ALL
,INTERSECT
,EXCEPT
(orMINUS
, depending on the database)