Skip to content

zamanmiraz/SQL_Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

SQL Practice

This repository contains SQL practice problems sourced from LeetCode SQL. Each file corresponds to a specific LeetCode question, and the lessons learned from solving these problems are documented below.


LeetCode SQL Practice

This folder contains SQL practice problems from LeetCode. Each file is named after the corresponding LeetCode question.


Lessons Learned

Below is a table summarizing the key lessons and concepts learned from each LeetCode question.

LeetCode Question # Description
618 Learn pivot
1083 Computational time for subquery vs. join.
1107 Using DATEDIFF(date1, date2) to calculate the difference between two dates.
1112 Window functions. Watch this YouTube tutorial.
1142 Using IFNULL(value, replace_value) to handle null values.
1158 Understanding the effect of placing the WHERE clause.
1164 Performance optimization using JOIN and IN clauses.
1173 Learning the AVG function.
1179, 1193 Practicing aggregate functions during GROUP BY.
1193 Learning DATE_FORMAT for formatting dates.
1204 Practicing window functions with ORDER BY and PARTITION BY.
1205 Must practice FULL JOIN, LEFT JOIN, and RIGHT JOIN.
1212 Practicing and finding better time complexity.
1264 Practicing and finding better time complexity.
1270 Practicing JOIN operations.
1285 Must practice.
1308 Practicing the OVER clause.
1321 Must practice.
1341 Using UNION ALL and LIMIT.
1393 Learning the CASE function.
1454 Using DATE_SUB, RANK, window functions, and INTERVAL.
1484 Learning GROUP_CONCAT.
1517, 1527 Practicing regular expressions (REGEXP). See notes here.
1613 Learning Recursive CTEs. See notes here.
1699 Learning LEAST, GREATEST.
1783 Conditional Aggregation
2228 Lag Function
1336 Recursive CTE

Key Concepts

  1. Joins:

    • INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN.
    • Performance optimization using joins.
  2. Window Functions:

    • ROW_NUMBER(), RANK(), DENSE_RANK().
    • PARTITION BY and ORDER BY.
  3. Date Functions:

    • DATEDIFF, DATE_FORMAT, DATE_SUB, INTERVAL.
  4. Aggregate Functions:

    • AVG, GROUP_CONCAT, COUNT, SUM.
  5. Conditional Logic:

    • CASE statements.
    • IFNULL for handling null values.
  6. Recursive CTEs:

    • Generating sequences.
    • Traversing hierarchical data.
  7. Regular Expressions:

    • Using REGEXP for pattern matching.

Resources

  1. LeetCode SQL Problems
  2. Window Functions Tutorial
  3. Regular Expressions Notes
  4. Recursive CTE Notes

About

SQL Practice from different Source

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published