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
SQL Cheat Sheet: Phase 1 Complete, Phase 2 Starts Monday
More Relevant Posts
-
✅ 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
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
-
-
Day 20 – CASE Statement My manager once asked me: "Can you label every customer as Gold, Silver or Bronze based on their spending?" Before I knew CASE, I'd write 3 separate queries and paste them in Excel. After CASE, I did it in 6 lines of SQL. The CASE statement is SQL's version of if / else. It checks conditions one by one and returns the first match. Basic structure: CASE WHEN condition THEN result WHEN condition THEN result ELSE default END AS column_name 4 things you can do with CASE: 1.Label numbers → Score 90+ = 'A', 75+ = 'B', else 'C' 2.Map text codes → Status 'A' = 'Active', 'D' = 'Delivered' 3.Conditional COUNT → Count active vs inactive in ONE query Conditional 4.SUM → Online revenue vs offline revenue in ONE query That last two are game-changers. No subqueries. No Excel. Just SQL. Day 20 / 60 — SQL for Beginners series. Follow for a new concept every day. 🚀 #SQL #LearnSQL #SQLforBeginners #DataAnalytics #TechCareer #DataScience
To view or add a comment, sign in
-
-
When you finally overcome a hurdle in SQL, it can feel like a win! 😀 When it comes to maintaining skill in intermediate to advanced topics, a query a day should suffice. This helps to prevent atrophying of the skills you have acquired during those SQL practice-filled days. Today's goal: Practice using the LAG() window function. I remember seeing this query a few months back that asked to return only the dates where the current day's temperature was warmer than the previous day's temperature. Back then, I could not even get close to getting the correct query. Note: When doing these queries, I do not look at the solution prior to submitting as I would only be cheating myself. After submitting my solution, I took a peek and it did involve using a self-join. Key takeaways from today's daily SQL session: ✔️ When using the LAG() window function it is common practice to ORDER BY the date in ascending order within the function itself. I used this function to pull the previous row's temperature and date. ✔️ Testing for edge cases: The query specifically asks for days in which the temperature was warmer than the day prior (yesterday). Meaning, I had to make sure that results were returned in which there was no more than a one day gap. For instance; if a reading had been recorded for today, but the last recorded reading was last Friday, I would not want today's date to be returned even if it was warmer than last Friday. ✔️ DATEDIFF(): Utilized this function in the WHERE clause to filter out rows with more than a one-day gap thus only comparing consecutive days. ✔️ CTE usage: Better readability than when trying to nest everything in a subquery. ✔️ With repetition over time, skills will be further solidified so that even if you are to take a short hiatus, you will not forget as much. How would have you solved this query? 🤔 #CareerGrowth #SQL #SQLInterviewPractice #DataAnalytics #Challenge
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
-
-
💡 RANK() vs DENSE_RANK() vs ROW_NUMBER() in SQL 👉 If you're working with SQL window functions, understanding the difference between these three is very important. 1️⃣ RANK() ▪️ The same values get the same rank. ▪️ Skips numbers after ties 2️⃣ DENSE_RANK() ▪️ Same values get the same rank ▪️ No gaps in ranking 3️⃣ Row_Number() ▪️ Assigns a unique number to each row ▪️ No duplicates, even if values are the same 🔍 Key Difference ✔️ RANK() - Skips ranks on ties ✔️ DENSE_RANK() - No gaps in ranks ✔️ ROW_NUMBER() - Always unique #SQL #DataScience #DataAnalytics #Database #TechTips #LearningSQL #InterviewPrep
To view or add a comment, sign in
-
-
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
-
SQL Ranking Functions 🔹 ROW_NUMBER() Gives a unique number to each row. 👉 No ties, no gaps (1,2,3,4) 🔹 RANK() Same values get same rank. 👉 Gaps appear after ties (1,2,2,4) 🔹 DENSE_RANK() Same values get same rank. 👉 No gaps (1,2,2,3) Simple idea: - Need unique order → ROW_NUMBER - Okay with gaps → RANK - Want continuous ranking → DENSE_RANK #SQL #DataEngineering #PySpark #Databricks #SQLBasics #LearnSQL
To view or add a comment, sign in
-
-
My SQL broke. And I learned more from that than anything else. While building my Hospital Claim Denial & Revenue Recovery Analysis, I ran my department denial trends query and got this: ❌ ERROR: syntax error at or near "WITH" I stared at it for a while. Turns out I had written the same CTE twice in the same query — once as an explanation and once as the actual logic. PostgreSQL hit the second WITH keyword and stopped cold. The fix took 5 minutes. But the lesson stuck. → Writing clean, layered SQL means each CTE should do one thing → Comments explain the WHY — the code handles the HOW → A query that breaks loudly is easier to fix than one that runs silently wrong I've been building Project 2 of my analytics portfolio — a full end-to-end claims denial analysis using Excel, PostgreSQL, and Power BI. 5 SQL queries. CTEs. Window functions. A composite risk score. The bugs were part of the process. Dashboard is built. README is live on GitHub. Final results post coming soon. #LearningInPublic #AspiringDataAnalyst #SQL #PostgreSQL #HealthcareAnalytics #DataAnalytics #CareerChange What's a bug or mistake that taught you more than it cost you?
To view or add a comment, sign in
-
-
Day 26/90 — SQL Series | Week 4 "My WHERE clause is not filtering dates correctly." "My SUM is returning NULL instead of a number." 9 times out of 10 — it's a data type mismatch. CAST and CONVERT fix it. CAST('250' AS INT) → turns text into number so you can do math CAST('2024-01-15' AS DATE) → turns text into date so filters work CAST(order_id AS VARCHAR) → turns number into text for concatenation Rule: use CAST (works everywhere). Use CONVERT only when you need date formatting in SQL Server. #SQL #CastConvert #DataAnalytics #LearnSQL #DataAnalyst
To view or add a comment, sign in
-
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