SQL Progress: Aggregations & Joins! What I learned and practiced today: 1. Aggregate Functions: It’s becoming easier to decide when to use GROUP BY and how to handle multiple aggregations in one query. 2. Data Precision: Handling decimal calculations and rounding is becoming second nature now. It’s all about making the final output clean and professional. I love to learn from you! If you have any tips or a better way to solve these, please type them in the comments! قليل مستمر خير من كثير منقطع #SQL #DataEngineering #PostgreSQL #LeetCode #100DaysOfCode #LearningInPublic #ProblemSolving #DataAnalytics
SQL Aggregations & Joins Best Practices
More Relevant Posts
-
Stop treats 'NULL' like it's just 'nothing'! Knowing the difference between NULL, an Empty String (''), and a Blank Space (' ') isn't just about syntax—it’s critical for data integrity and accurate reporting. I've combined these concepts into one comprehensive 'Nullability Masterclass' infographic to show you exactly how they differ across: 1) Data Type & Representation 2) Storage & Performance 3) The best functions for handling them (like COALESCE and NULLIF) This cheat sheet will save you hours of debugging and help you write more resilient queries. Save this post for later, and let me know your favorite SQL tip for handling missing values below! #SQL #DataAnalytics #DataScience #PostgreSQL #DataEngineering #MySQL #DatabaseManagement
To view or add a comment, sign in
-
-
Solving crimes with SQL? 🕵️♂️ I spent last weekend tracking down a murderer. With SQL queries. SQL Murder Mystery and SQL Noir are detective games where you interrogate databases instead of suspects. You write JOINs to find witnesses, subqueries to track alibis, aggregate functions to piece together timelines. Way more engaging than running the same practice queries on sample data. What clicked for me: you can't just memorize syntax. You have to think about which tables to join and why. The cases get harder as you go, so you end up using window functions and CTEs without it feeling like homework. Worth checking out if you're working with MySQL or PostgreSQL and want practice that doesn't feel like practice. 🔗 SQL Murder Mystery : https://lnkd.in/gq3V458e 🔗 SQL Noir : https://www.sqlnoir.com/ What SQL learning tools have actually worked for you? Always looking for recommendations. #SQL #DataAnalytics #MySQL #PostgreSQL #LearningAndDevelopment
To view or add a comment, sign in
-
🚀 Just Published My New Blog on MySQL! As part of my Data Science journey, I recently worked on a blog explaining MySQL commands using flowcharts — and it really helped me understand concepts more clearly. Instead of memorizing queries, I focused on understanding the flow and purpose behind each SQL command category: 🔹 DDL – Structure 🔹 DML – Data operations 🔹 DCL – Access control 🔹 TCL – Transactions 🔹 DQL – Queries 📊 I also included a simple flowchart and real examples to make it beginner-friendly. Big thanks to my mentor Koduri Srihari and trainer Manohar Chary .V for their guidance and support throughout this learning process 🙌 Grateful to Innomatics Research Labs for providing such structured learning opportunities. 🔗 Read the full blog here: https://lnkd.in/gXVnDhYN Would love to hear your feedback! #MySQL #SQL #DataScience #LearningJourney #BeginnerFriendly #Database #Growth
To view or add a comment, sign in
-
𝗙𝗜𝗟𝗧𝗘𝗥 𝗰𝗹𝗮𝘂𝘀𝗲 — 𝗰𝗹𝗲𝗮𝗻𝗲𝗿 𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹 𝗮𝗴𝗴𝗿𝗲𝗴𝗮𝘁𝗶𝗼𝗻 CASE WHEN inside aggregations is everywhere. But there's a cleaner way in modern SQL. The 𝗙𝗜𝗟𝗧𝗘𝗥 clause. Old way: SELECT SUM(CASE WHEN status = 'paid' THEN amount END) AS paid, SUM(CASE WHEN status = 'pending' THEN amount END) AS pending FROM orders; New way with FILTER: SELECT SUM(amount) FILTER (WHERE status = 'paid') AS paid, SUM(amount) FILTER (WHERE status = 'pending') AS pending FROM orders; Same result. Much cleaner. Works with COUNT, AVG, MIN, MAX — any aggregate function. The best SQL isn't always the most complex — sometimes it's just more readable. Have you used FILTER before? #SQL #DataAnalysis #PostgreSQL #DataEngineering #Analytics
To view or add a comment, sign in
-
Why NOT EXISTS is faster than LEFT JOIN (in many cases) Both queries solve the same problem: Find records that don’t have a match But internally, they behave very differently. LEFT JOIN: • Joins entire tables • Creates intermediate result • Then filters NULLs NOT EXISTS: • Checks row by row • Stops at first match • Avoids unnecessary scans LEFT JOIN = “process everything, then filter” NOT EXISTS = “check and skip early” That’s why NOT EXISTS often performs better on large datasets. But remember: Modern SQL optimizers can rewrite both — always check execution plans. Small query change. Big performance difference. #SQL #SQLTips #AdvancedSQL #QueryOptimization #Database #DataEngineering #Analytics #SQLServer #PostgreSQL #CodingTips
To view or add a comment, sign in
-
-
🚀 Day 29 of My SQL Journey – 𝗦𝘂𝗯𝗾𝘂𝗲𝗿𝗶𝗲𝘀 (𝗕𝗮𝘀𝗲𝗱 𝗼𝗻 𝗟𝗼𝗰𝗮𝘁𝗶𝗼𝗻) Today I focused on understanding how subqueries can be used based on their location within SQL queries. Instead of just learning concepts, I explored where exactly subqueries fit in real-world scenarios. 🔹 𝗦𝘂𝗯𝗾𝘂𝗲𝗿𝘆 𝗶𝗻 𝗦𝗘𝗟𝗘𝗖𝗧 – Used to display calculated values alongside each row 🔹 𝗦𝘂𝗯𝗾𝘂𝗲𝗿𝘆 𝗶𝗻 𝗪𝗛𝗘𝗥𝗘 – Helps filter data based on conditions 🔹 𝗦𝘂𝗯𝗾𝘂𝗲𝗿𝘆 𝗶𝗻 𝗙𝗥𝗢𝗠 (Derived Table) – Creates temporary tables for further analysis 🔹 𝗦𝘂𝗯𝗾𝘂𝗲𝗿𝘆 𝗶𝗻 𝗛𝗔𝗩𝗜𝗡𝗚 – Filters grouped results using aggregate conditions 💡 𝗞𝗲𝘆 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Subqueries make complex problems easier by breaking them into smaller steps and placing logic exactly where it’s needed. 📊 Practicing these concepts is helping me think more analytically and write more efficient SQL queries. #SQL #LearningJourney #DataAnalytics #Database #SQLQueries #Subqueries #TechSkills #StudentDeveloper
To view or add a comment, sign in
-
-
💡 Quick SQL Trick: Count Vowels in a String Want to count vowels (a, e, i, o, u) in a column? Use LENGTH and REPLACE for a clean solution: ✅ How it works: 🔹 REPLACE(name, 'a', '') removes 'a' from the string. 🔹 Subtracting the new length from the original length gives the count of 'a'. 🔹 Repeat for all vowels and sum them up. 🔹 This approach is simple, fast, and works in almost any SQL flavor! #SQLTips #DataScience #Database #VowelCount #CodingMadeEasy #LearnSQL
To view or add a comment, sign in
-
-
You do not need to memorise every SQL function. You need to know where to find them when you need them. 📌 So I built a complete SQL reference guide 115 functions and clauses across 10 categories, every one with syntax, plain English explanation and a real copy-paste example. Here is everything inside 👇 📐Data Retrieval: SELECT, DISTINCT, ORDER BY, LIMIT, UNION, INTERSECT 🔗Joins: INNER, LEFT, RIGHT, FULL OUTER, CROSS, SELF JOIN 📊Aggregation: COUNT, SUM, AVG, GROUP BY, HAVING, ROLLUP 🔀Filtering and Logic: IN, BETWEEN, LIKE, EXISTS, CASE WHEN, NULLIF 📝String Functions: CONCAT, TRIM, SUBSTRING, REPLACE, STRING_AGG 📅Date and Time: YEAR, MONTH, DATE_TRUNC, DATEDIFF, EOMONTH 🔢Math and Numeric: ROUND, FLOOR, CAST, NULLIF, GREATEST, LEAST ⚡Window Functions: ROW_NUMBER, RANK, LAG, LEAD PERCENT_RANK 🏗️Table Operations: CREATE, INSERT, UPDATE, DELETE, ALTER, INDEX, VIEW 🧠 Advanced SQL: CTEs, Subqueries, PIVOT, EXPLAIN, Recursive CTEs 115 functions. 10 categories. Real examples for every single one. 🎯 Which SQL function do you use most in your daily work? 👇 #SQL #DataAnalyst #SQLReference #DataAnalytics #SQLServer #MySQL #PostgreSQL #DataScience #Analytics #FreeResource #SaveThis #BusinessIntelligence #DataDriven #CareerGrowth #Upskilling #TechSkills #DataEngineering #WindowFunctions #DataCommunity #DataVisualization
To view or add a comment, sign in
-
🚀 Day 26 – SQL Learning Journey Today’s focus was on one of the most powerful concepts in SQL: Subqueries & Correlated Subqueries 🔍 🔹 Subqueries (Inner Queries) - A query written inside another query - Used to break complex problems into simpler steps - Can be used in "SELECT", "WHERE", or "FROM" clauses - Example use: finding customers with above-average spending 🔹 Correlated Subqueries - A subquery that depends on the outer query - Executes row-by-row, making it more dynamic - Useful for comparisons within groups (like per customer, per store, etc.) 💡 Key Learnings: ✔ Simplified complex filtering logic ✔ Learned when to use subqueries vs joins ✔ Understood performance impact of correlated queries ✔ Practiced real-world scenarios like ranking, filtering, and segmentation 📊 Realizations: Subqueries are great for clarity, but correlated subqueries require careful use due to performance considerations. Consistency is the key 🔥 — one step closer to mastering SQL! #SQL #DataAnalytics #LearningJourney #Subqueries #CorrelatedSubqueries #Day26 generate a image and take a example of dataset
To view or add a comment, sign in
-
-
🚀 Day 28 of SQL Journey – Subqueries (Part 3) Today, I explored an important classification of subqueries based on dependency: Correlated and Non-Correlated Subqueries 🔍 🔹 Correlated Subqueries These subqueries depend on the outer query and execute once for every row processed. While powerful for row-wise comparisons, they can be slower due to repeated execution. 🔹 Non-Correlated Subqueries These are independent of the outer query and execute only once. They are more efficient and ideal when a single aggregated result is sufficient. 📊 The key difference lies in execution behavior and performance impact. Choosing the right type of subquery can significantly optimize your queries. 💡 Key Insight: Use correlated subqueries for dynamic, row-level comparisons, and non-correlated subqueries for static, overall comparisons. #SQL #Learning #DataAnalytics #Database #SQLJourney #40DaysOfCode
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