DEV Community

Cover image for πŸ“Š SQL Learning Journey β€” Week 4 Recap
Yogaraj
Yogaraj

Posted on

πŸ“Š SQL Learning Journey β€” Week 4 Recap

🧠 Key Concepts Explored

πŸ§ͺ Subqueries Simplified

Subqueries are powerful tools in SQL. This week, I learned that:

  • Subquery is independent β€” it returns a value.
  • Outer query uses that value, applying it across the main table.

πŸ’‘ Golden Rule for Subqueries:

Don't try to understand the whole table first. Instead, zoom in:

  1. Who should be in the result?
  2. What is the condition to qualify?
  3. What’s the minimal data I need?

🎯 3-Step SQL Problem Solving Template:

Step Question Example Thought
1 Who is the output about? Authors
2 What must they have done? Viewed their own article
3 What’s the SQL logic? author_id = viewer_id β†’ SELECT DISTINCT author_id

🧰 Handy Functions

Function Purpose Syntax Example Result
DATE_ADD() Adds interval to date DATE_ADD('2025-08-06', INTERVAL 1 DAY) 2025-08-07
DATE_SUB() Subtracts interval from date DATE_SUB('2025-08-06', INTERVAL 1 DAY) 2025-08-05

🧾 ENUM Usage

ENUM is a data type used to restrict column values to a predefined set.

Example:

status ENUM('Pending', 'Shipped', 'Delivered', 'Cancelled')
Enter fullscreen mode Exit fullscreen mode
  • Only those 4 values are allowed.
  • You can include numbers, but they’re stored as strings, not integers.

βœ… LeetCode Practice β€” 10 Problems Solved πŸŽ‰

This week, I tackled and completed 10 beginner-friendly SQL problems:

Problem No. Title Difficulty
1757 Recyclable and Low Fat Products Easy
584 Find Customer Referee Easy
595 Big Countries Easy
1148 Article Views I Easy
1683 Invalid Tweets Easy
1378 Replace Employee ID With The Unique Identifier Easy
1068 Product Sales Analysis I Easy
1581 Customer Who Visited but Did Not Make Any Transactions Easy
197 Rising Temperature Easy
1661 Average Time of Process per Machine Easy
577 Employee Bonus Easy

🌱 What’s Next?

  • Dive deeper into Window Functions
  • Explore Advanced Subqueries and Nested Joins
  • Build a mini-project using real-world datasets

Thanks for reading! Feel free to connect and share your learning journey too. πŸ’¬

#SQL #100DaysOfSQL #LearningJourney #Subqueries #LeetCode

Top comments (0)