🚀 Day 50 of My SQL Learning Journey Today I solved a medium-level SQL problem involving user retention analysis 🔥 🔹 Problem: Find the fraction of players who logged in again the day after their first login 🔗 Problem Link: https://lnkd.in/gsSuBeg5 🔹 Solution: SELECT ROUND( COUNT(DISTINCT a.player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) AS fraction FROM Activity a JOIN ( SELECT player_id, MIN(event_date) AS first_login FROM Activity GROUP BY player_id ) f ON a.player_id = f.player_id AND a.event_date = DATE_ADD(f.first_login, INTERVAL 1 DAY); 🔹 Key Learning: Using subqueries to find first login Applying date functions (DATE_ADD) Calculating ratios using aggregation Real-world concept: user retention analysis 💡 SQL is powerful for analyzing user behavior and retention patterns! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #DataAnalytics #InterviewPreparation
SQL user retention analysis with subqueries and date functions
More Relevant Posts
-
✅ Solved a SQL problem on LeetCode — Day 48 of my SQL Journey 💪 Not all active users are valuable… Some look busy 👀 Today’s problem was about identifying zombie sessions — users who scroll endlessly but never click, never buy, never engage. Active on paper. Dead in reality. The approach: • Calculated session duration using MIN() and MAX() timestamps • Counted scrolls and clicks with conditional aggregation • Computed click-to-scroll ratio inside HAVING • Filtered sessions: duration > 30 min, scrolls ≥ 5, ratio < 0.20, zero purchases What I practised: • Conditional aggregation using CASE WHEN • Session-level grouping • Ratio logic inside HAVING • Translating behaviour into SQL filters What stood out — Scrolling is passive. Clicking is intent. Buying is a commitment. A session full of scrolls but no clicks It's just a ghost. That’s where the real insight lies. SQL doesn’t just count events. It reads the story behind them. Consistent learning, one query at a time 🚀 #SQL #LeetCode #DataAnalytics #LearningInPublic #SQLPractice
To view or add a comment, sign in
-
-
🚀 Day 32 of My SQL Learning Journey Today I practiced a SQL problem based on JOIN operations 🔹 Problem: Retrieve product name, year, and price for each sale 🔗 Problem Link: https://lnkd.in/gBgY3zhW 🔹 Key Learning: Using JOIN to combine multiple tables Retrieving meaningful data from relational databases Importance of foreign key relationships 💡 JOINs are one of the most important concepts in SQL! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #DataAnalytics #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 40 of My SQL Learning Journey Today I worked on a SQL problem involving aggregation and string manipulation 🔥 🔹 Problem: Group sold products by date and list them in sorted order 🔗 Problem Link: https://lnkd.in/gp6qVmNt 🔹 Solution: SELECT sell_date, COUNT(DISTINCT product) AS num_sold, GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR ',') AS products FROM Activities GROUP BY sell_date; 🔹 Key Learning: Using COUNT(DISTINCT) for unique values Combining rows using GROUP_CONCAT() Sorting values inside aggregation 💡 SQL can generate clean reports directly from raw data! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #DataAnalytics #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 2 of My SQL Learning Journey Today I learned about the WHERE clause in SQL. 👉 WHERE is used to filter data based on specific conditions. Basic syntax: SELECT column_name FROM table_name WHERE condition; ✔ Helps in retrieving only the required data ✔ Can be used with operators like =, >, <, AND, OR 💡 Learning WHERE made me realize how powerful SQL is when working with large datasets. Excited to keep improving! 🔥 Next: INSERT statement 👀 #SQL #LearningJourney #Beginner #DataAnalytics #Day2 #LearnInPublic
To view or add a comment, sign in
-
-
I do hear people talk about how hard SQL can be, but I didn't truly get it until I started learning it myself. The beginning was a bit of a whirlwind between installing the software, setting everything up, and trying to keep up with the lessons i felt a bit lost. I actually had to take a break for a while to clear my head but the good news is i got back on track quickly! Why SQL is such a powerhouse: It is way more than just pulling data from a table. It’s like learning a new language to talk to databases. The Logic: Using JOINS to connect different tables together like a puzzle. The aggregation: Using functions like SUM, COUNT, and AVG to turn thousands of rows into useful numbers. The Precision: Learning how to use WHERE and HAVING to find exactly what you need. SQL isn't easy and it’s okay to admit that. There are moments when the code doesn't run and you feel frustrated but that’s all part of the process. I am still learning, still growing and I’m not giving up. The journey continues! #SQL #DataAnalysis #LearningToCode #TechJourney #DataAnalytics #Techcrush
To view or add a comment, sign in
-
-
🚀 Day 44 of My SQL Learning Journey Today I solved a SQL problem involving aggregation and distinct counting 🔥 🔹 Problem: Find number of unique leads and partners per day 🔗 Problem Link: https://lnkd.in/gXnubrbd 🔹 Solution: SELECT date_id, make_name, COUNT(DISTINCT lead_id) AS unique_leads, COUNT(DISTINCT partner_id) AS unique_partners FROM DailySales GROUP BY date_id, make_name; 🔹 Key Learning: Using multiple COUNT(DISTINCT) Grouping by multiple columns Real-world reporting queries 💡 SQL helps transform raw data into meaningful insights! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #DataAnalytics
To view or add a comment, sign in
-
-
🚀 Day 51 of My SQL Learning Journey Today I solved a SQL problem involving joins and conditional filtering 🔥 🔹 Problem: Find employees whose bonus is less than 1000 or who didn’t receive any bonus 🔗 Problem Link: https://lnkd.in/gF6_J-Vr 🔹 Solution: SELECT e.name, b.bonus FROM Employee e LEFT JOIN Bonus b ON e.empId = b.empId WHERE b.bonus < 1000 OR b.bonus IS NULL; 🔹 Key Learning: Using LEFT JOIN to include unmatched records Handling NULL values properly Applying conditions with multiple filters 💡 Understanding joins is essential for solving real-world database problems! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Today I learned something interesting while solving SQL problem 👇 I used ROUND() thinking it will convert integer to decimal ❌ But I realized: ROUND() only formats output, it does NOT change datatype. 👉 Example: 5 / 2 = 2 5 / 2.0 = 2.5 Small learning, but important for avoiding wrong results. #SQL #LearningDaily
To view or add a comment, sign in
-
🚀 Day 7 of My SQL Learning Journey Today I learned about CASE WHEN in SQL, a powerful feature used to apply conditional logic inside SQL queries. It works similar to IF–ELSE logic in programming and helps transform raw data into meaningful insights. 📚 Topics Covered: 🔹 CASE WHEN (Conditional Logic) Learned how CASE WHEN is used to show different results based on conditions within a query. 🔹 SUM + CASE WHEN Practiced combining SUM with CASE WHEN to calculate totals for specific conditions, such as total sales for a particular product category. 🔹 COUNT + CASE WHEN Used COUNT with CASE WHEN to count rows that satisfy certain conditions, such as counting pass/fail students or active customers. 🔹 CASE WHEN Syntax Rules Understood that every CASE statement starts with CASE and ends with END, with conditions defined using WHEN and results returned using THEN. 🔹 CASE WHEN with GROUP BY Learned how CASE WHEN can be applied with GROUP BY to perform conditional calculations on grouped data. 🔹 CASE WHEN with WHERE Explored how CASE WHEN can help apply dynamic filtering conditions inside the WHERE clause. 💡 Key Learning: CASE WHEN allows us to add decision-making logic directly inside SQL queries, making it easier to create conditional calculations and customized reports. #SQL #SQLLearning #DataAnalytics #LearningJourney #Database #DataSkills
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on LeetCode — Day 47 of my SQL Journey 💪 Learning doesn’t always move in a straight line… sometimes it spirals 🔄 Today’s problem was about identifying students who follow a study spiral pattern — studying multiple subjects in a structured, repeating cycle. The approach: • Tracked session order using ROW_NUMBER() • Measured gaps between sessions with LAG() and DATEDIFF() • Filtered sequences with gaps longer than 2 days • Detected repeating cycles using MOD() on row position • Counted students with at least 3 subjects across multiple cycles What I practised: • Window functions for sequence tracking • Time gap detection using date functions • Sequential pattern recognition • Using HAVING for conditional aggregation What stood out — A single session tells you nothing… A sequence tells you everything. Patterns don’t announce themselves, They hide in the order of events. That’s where the real insight lies. SQL doesn’t just query data. It helps read the story behind it. Consistent learning, one query at a time 🚀 #SQL #LeetCode #DataAnalytics #LearningInPublic #SQLPractice
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development