✅ Solved a SQL problem on StrataScratch — Day 51 of my SQL Journey 💪 After 50 days on LeetCode, I’ve started focusing more on real-world, business-driven SQL problems 📊 Today’s problem was about analysing how rankings change over time — not just activity, but improvement in position. I worked on: • Aggregating total comments per country by month • Ranking countries within each month using DENSE_RANK() • Comparing rankings between December and January • Identifying countries whose rank improved What I practised: • Window functions for ranking • Time-based aggregation using DATE functions • Comparing metrics across time periods • Turning raw activity into performance insights What stood out — Growth isn’t always about higher numbers. It’s about moving ahead. A country can increase activity… Yet still fall behind others. That’s why relative performance matters more than absolute values. SQL helps uncover not just change… but meaningful change. Consistent learning, one query at a time 🚀 #SQL #StrataScratch #DataAnalytics #LearningInPublic #SQLPractice
Sourav Mukherjee’s Post
More Relevant Posts
-
In January, my community ran a 34-day SQL challenge hosted by Silvia W. where we solved interview-style business questions daily. And wow… that experience changed how I think. It forced me to slow down and ask a different question: Not just: “What query should I write?” But: “What is this question really asking for?” One major lesson stood out to me: SQL will give you exactly what you ask for whether you’re right or wrong. And that’s the scary part. Your query can run perfectly… And still give you the wrong answer. That experience reinforced something I had started to realize: SQL is not just about writing queries. Understanding the logic behind the problem is the real skill. In my next post, I’ll share another mistake that can completely ruin your results. #DataAnalytics #SQL #LearningJourney #DataAnalysis
To view or add a comment, sign in
-
Day 35/90 — Week 5 complete. Phase 2 has officially started and this week was big. Here is the full cheat sheet — save it. CASE WHEN: → SQL's if/else — classify rows into labelled segments → Use with GROUP BY to count each segment in one query Subquery in WHERE: → WHERE amount > (SELECT AVG(amount) FROM orders) → Filters dynamically — recalculates every time Subquery in FROM: → Wrap a query in FROM to create a virtual table → Always alias it — FROM (...) AS my_table Correlated subquery: → References the outer query's columns → Runs once per row — powerful but can be slow on large data Master query using all of this week: Filter above-average orders → classify each city by tier → count per tier All in a single SQL statement. Week 6 starts Monday — CTEs. The cleaner, more readable alternative to nested subqueries. Follow so you don't miss it. Tag someone who is learning SQL and needs this cheat sheet. #SQL #CaseWhen #Subquery #DataAnalytics #LearnSQL #Week5 #SQLCheatSheet #DataAnalyst
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on StrataScratch — Day 54 of my SQL Journey 💪 User activity looks simple… until you try to measure it correctly ⏱️ Today’s problem was about calculating average session time — But sessions weren’t explicitly given. They had to be built from events. The approach: • Identified session boundaries using page_load and page_exit • Used MIN() and MAX() with CASE WHEN to capture valid timestamps • Calculated session duration using TIMESTAMPDIFF() • Filtered out invalid sessions (where load happens after exit) • Averaged session time per user What I practised: • Event-based session reconstruction • Conditional aggregation using CASE WHEN • Time difference calculations in SQL • Data cleaning before aggregation What stood out — Metrics don’t exist in raw data. You have to build them. A “session” isn’t stored anywhere… It’s something you define from behaviour. That’s where analysis actually begins. Consistent learning, one query at a time 🚀 #SQL #StrataScratch #DataAnalytics #LearningInPublic #SQLPractice
To view or add a comment, sign in
-
-
Day 28/90 — Phase 1 complete. 4 weeks. 28 posts. Every SQL foundation covered. Here is the full cheat sheet — save it now. Week 1 — Core queries: SELECT, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT Week 2 — JOINs: INNER, LEFT, RIGHT, FULL OUTER, SELF Week 3 — Functions: COUNT/SUM/AVG/MAX/MIN, DISTINCT, LIKE, IN, BETWEEN, String functions Week 4 — Date & NULL: GETDATE, DATEPART, DATEDIFF, IS NULL, ISNULL, COALESCE, CAST If you can write this query without help — you are interview-ready for Phase 1: SELECT city, SUM(amount) AS revenue, COUNT(*) AS orders FROM orders WHERE amount > 500 AND DATEPART(YEAR, order_date) = 2024 GROUP BY city HAVING SUM(amount) > 10000 ORDER BY revenue DESC; Phase 2 starts Monday — Subqueries, CTEs, Window Functions. The intermediate level. Follow so you don't miss it. Tag someone who needs this cheat sheet. #SQL #DataAnalytics #LearnSQL #Phase1 #DataAnalyst #SQLCheatSheet
To view or add a comment, sign in
-
-
🚀 Most SQL queries don't fail - they just 𝐬𝐥𝐨𝐰 𝐲𝐨𝐮 𝐝𝐨𝐰𝐧. And 9 times out of 10, the culprit is something you could have fixed with two powerful (and often overlooked) tools: 𝐕𝐢𝐞𝐰𝐬 𝐚𝐧𝐝 𝐈𝐧𝐝𝐞𝐱𝐞𝐬. Understanding Views and Indexes isn't just a "nice to have" - it's the difference between a query that crawls and one that flies. Whether you're working with millions of rows or building dashboards that need to refresh in real time, mastering these concepts is what separates good SQL from great SQL. ✅ What are Views ✅ How Indexes work under the hood (and why the wrong one can make things worse) ✅ Real-world patterns to optimize query performance dramatically ✅ Common mistakes developers make - and how to avoid them 🎙️ All of this and more is covered in the latest episode of SQL Series - "SQL Performance Optimizations: Views & Indexes in SQL!" If you've ever stared at a slow query and wondered *why*, this one's for you. 👇 🔗Click here to watch: https://lnkd.in/gki5-X6r #SQL #DataEngineering #DatabaseOptimization #SQLPerformance #TechPodcast #LearningSQL #DataAnalytics #SoftwareEngineering
To view or add a comment, sign in
-
-
Most people learn SQL… But get confused the moment JOIN comes into the picture. Because JOIN is not just syntax. It’s about understanding relationships between tables. Let’s simplify it ➥ INNER JOIN : Returns only matching records from both tables. Think: “Show me what exists in both.” ➥ LEFT JOIN : Returns all records from the left table + matched records from the right table. Think: “Show me everything from left, even if right is missing.” ➥ RIGHT JOIN : Returns all records from the right table + matched records from the left table. Think: “Show me everything from right, even if left is missing.” ➥ FULL JOIN (FULL OUTER JOIN) : Returns all records from both tables. Think: “Show me everything, matched or not.” #SQL #Database #DataEngineering #BackendDevelopment #TechLearning #SoftwareEngineering
To view or add a comment, sign in
-
-
Last week SQL finally started speaking my language. I learned SELECT, FROM, and WHERE. The three clauses that tell SQL exactly what you want, where to find it, and which conditions to apply. Then came subqueries. A query living inside another query. But here's what nobody tells you: You don't always need a subquery. If a simple clause gives you the right result, use it. Pro tip: On large databases, the right query isn't just about accuracy. it's about speed. Choose what loads faster. New week. New concept. © Intrigued by data #SQL #DataAnalytics #lerningInPublic #CareerGrowth
To view or add a comment, sign in
-
-
SQL is more than just code; it’s a tool for curiosity. 🔍 I just wrapped up a deep dive into SQL foundations. Instead of just following tutorials, I focused on real-world applications—asking questions of the data and building queries to find the answers. What I’ve been building: ✅ Multi-table JOINs to calculate total revenue. ✅ GROUP BY & COUNT logic to track yearly order volumes. ✅ Data segmentation using CASE statements for payment analysis. ✅ Clean reporting using DISTINCT and specific filtering. The goal wasn't just to get the query to "run," but to make it efficient and meaningful. Next stop: Window Functions and Subqueries! 🚀 #DataScience #SQL #LearningPublic #DataAnalyst #TechJourney
To view or add a comment, sign in
-
✅ Solved a SQL problem on StrataScratch — Day 58 of my SQL Journey 💪 User activity looks random… until you track it over time 📅 Today’s challenge: identify users active for 3 consecutive days or more. The approach: • Removed duplicate activity using DISTINCT • Used LEAD() to access upcoming activity dates • Compared dates using DATE_ADD() • Identified continuous activity sequences What I practised: • Window functions (LEAD) • Date-based comparisons • Sequential pattern detection • Writing logic-driven queries What stood out — Patterns don’t exist in single rows. They exist across time. Once you think in sequences, user behaviour becomes much clearer. SQL isn’t just about querying data — It’s about understanding behaviour. Consistent learning, one query at a time 🚀 #SQL #StrataScratch #DataAnalytics #LearningInPublic #SQLPractice
To view or add a comment, sign in
-
-
🚀 Day 13 – Data Analysis Journey | Daily SQL Challenge Continuing my daily SQL practice on HackerRank 💻 🧩 Problem Query the following two values from the STATION table: • The sum of all values in LAT_N rounded to 2 decimal places • The sum of all values in LONG_W rounded to 2 decimal places 💡 Approach • Used SUM() to calculate total values for both columns • Applied ROUND() function to limit the result to 2 decimal places • Combined both calculations into a single SELECT statement 🧠 Solution SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W), 2) FROM STATION; ⚠️ Challenge Faced Initially, I wrote two separate queries for LAT_N and LONG_W But realized that HackerRank expects the output in a single row with two columns. This helped me understand: 👉 Multiple aggregations can be done in one query 👉 Output format matters as much as logic 📚 Key Learning Efficient SQL queries combine multiple calculations in a single statement, improving performance and readability. 🔥 Staying consistent and improving SQL skills step by step! #Day13 #30DaysOfSQL #SQL #DataAnalytics #LearningJourney #HackerRank #Consistency #Aggregation 🚀
To view or add a comment, sign in
-
More from this author
Explore related topics
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