Stop confusing WHERE with HAVING. 🛑 One of the most common mistakes I see beginners make in SQL is trying to filter aggregated data using the WHERE clause. If you want to know the total sales per region, but only for regions that sold over $10k. you can’t do that without mastering the GROUP BY clause (and its best friend, HAVING). In the latest video of my SQL Tutorial Series, I break down: 📊 The logic of "Bucketing" data. 🔢 Using Aggregate functions (SUM, COUNT, AVG) with Group By. ✅ Real-world examples you'll actually see in a Data Analyst role. If you’ve been struggling to wrap your head around SQL aggregations, this 10-minute deep dive is for you. Watch the full tutorial Click the Link in the Comments. #SQL #DataAnalytics #Learning #DataEngineering #CareerGrowth
SQL Aggregations with GROUP BY and HAVING
More Relevant Posts
-
📊 Day 6/100: THE "SELECT" COMMAND Yesterday, we talked about queries, the questions we ask our data Mastering how and when to use the SELECT command is crucial, non-negotiable and a game changer in your journey as an analyst. with that being Today, let’s dive into the most important SQL command which is the SELECT command If SQL were a language, SELECT would be your voice. It allows you to retrieve data from a database. Simple, yet powerful. 🔹 Basic syntax: SELECT column_name FROM table_name; 🔹 Example: SELECT name, sales_amount FROM orders; This means: ➡️ “Show me the name and sales amount from the orders table.” 💡 Why SELECT matters: - It’s the foundation of data analysis - Every insight starts with retrieving the right data - It’s used in almost every SQL query (yes, almost ALL). #SQL #LearningInPublic #100Daysofanalysis #DataAnalyst #SelectCommand
To view or add a comment, sign in
-
-
🚀 DAY 15/30 – Window Functions (SQL) Most beginners use GROUP BY… But top data analysts use Window Functions 🔥 👉 Why? Because they analyze data WITHOUT losing detail 💡 What I learned today: ✅ A window function works across a set of rows (window) ✅ It does NOT reduce rows ✅ It adds extra insights to every row ⚡ Types you must know: 🔹 Ranking Functions → RANK() | DENSE_RANK() | ROW_NUMBER() 🔹 Aggregate Functions → SUM() | AVG() | COUNT() 🔹 Value Functions → LAG() | LEAD() | FIRST_VALUE() | LAST_VALUE() 🧩 Game Changer: PARTITION BY Split data into groups 👉 Like GROUP BY But keeps all rows (this is the magic ✨) 📊 Window vs GROUP BY ❌ GROUP BY → loses detail ✅ Window Functions → keep detail + add insights 💬 Big Insight: If you want to move from SQL learner → Data Analyst, 👉 Window functions are non-negotiable #SQL #DataAnalytics #WindowFunctions #LearningInPublic #DataAnalyst
To view or add a comment, sign in
-
-
🚀 𝗠𝗮𝘀𝘁𝗲𝗿 𝗦𝗤𝗟 𝗪𝗶𝗻𝗱𝗼𝘄 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 If you're working with SQL and still relying heavily on GROUP BY, it's time to level up your skills. Window Functions allow you to perform calculations across rows without collapsing your dataset. This means you can: ✔ Rank data ✔ Calculate running totals ✔ Compare rows within the same result set All while keeping your original data intact. 🔍 𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝗕𝗲𝘁𝘄𝗲𝗲𝗻 𝗥𝗔𝗡𝗞(), 𝗗𝗘𝗡𝗦𝗘_𝗥𝗔𝗡𝗞() & 𝗥𝗢𝗪_𝗡𝗨𝗠𝗕𝗘𝗥() These are the most commonly used window functions for ranking 👇 👉 𝗥𝗢𝗪_𝗡𝗨𝗠𝗕𝗘𝗥() Assigns a unique number to each row. Even if values are the same, the numbering will be different. 👉 𝗥𝗔𝗡𝗞() Gives the same rank to duplicate values, but skips the next rank. Example: 1, 2, 2, 4 👉 𝗗𝗘𝗡𝗦𝗘_𝗥𝗔𝗡𝗞() Also gives the same rank to duplicates, but does NOT skip ranks. Example: 1, 2, 2, 3 💡 𝗪𝗵𝗲𝗻 𝘁𝗼 𝗨𝘀𝗲 𝗪𝗵𝗮𝘁? Use 𝗥𝗢𝗪_𝗡𝗨𝗠𝗕𝗘𝗥() → when you need unique ordering (no duplicates) Use 𝗥𝗔𝗡𝗞() → when gaps in ranking are acceptable Use 𝗗𝗘𝗡𝗦𝗘_𝗥𝗔𝗡𝗞() → when you want continuous ranking #SQL #WindowFunctions #DataAnalytics #LearnSQL #SQLInterview #DataAnalyst #DataEngineering
To view or add a comment, sign in
-
-
📊SQL Cheat Sheet Every Data Analyst Should Know If you're learning Data Analytics, SQL is a must have skill.From filtering data to combining tables and using window functions, SQL helps transform raw data into actionable insights. Here's a quick SQL cheat sheet covering essential commands like: • SELECT, WHERE • GROUP BY & HAVING • JOINs(INNER, LEFT, RIGHT, FULL) • CASE WHEN • Window Functions like ROW_NUMBER() Saving this for quick revision while practicing SQL queries. What SQL function do you use the most?👇 #SQL #DataAnalytics #DataAnalyst #DataScience #LearningSQL #TechLearning
To view or add a comment, sign in
-
-
Day 2 of learning SQL 🚀 Today I moved beyond basics and learned how to analyze data using: ✔ GROUP BY – grouping data by category ✔ ORDER BY – sorting results (ASC / DESC) ✔ Aggregate functions: SUM() → total AVG() → average COUNT() → total rows MAX() / MIN() → highest & lowest ✔ Learned the difference between: WHERE → filters rows HAVING → filters grouped data Example I practiced: SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000 ORDER BY AVG(salary) DESC; Big realization today 💡 GROUP BY works with aggregate functions, and HAVING is used when filtering grouped results (not WHERE). Still making small mistakes, but improving every day. Goal: Become job-ready in SQL & Data Analysis 💪 #SQL #DataAnalytics #LearningInPublic #BeginnerToPro #100DaysOfCode
To view or add a comment, sign in
-
-
📊 Day 49/90 — SQL Learning: Grouping Data (GROUP BY) Today I learned how to summarize data using: 👉 GROUP BY clause This is where SQL starts becoming really powerful 🔥 Here’s what I practiced: ✅ Grouping data based on a column ✅ Using "COUNT()" to count records ✅ Using "SUM()" to calculate totals ✅ Using "AVG()" for averages ✅ Combining "GROUP BY" with "WHERE" Example: 👉 Total sales by region 👉 Number of customers per city 💡 Big lesson: Raw data gives information. Grouped data gives insights. Because: Individual rows → Hard to understand 😵💫 Grouped data → Clear patterns 📊 From today, I’ll focus on extracting insights using GROUP BY. 💬 What do you use most: COUNT, SUM, or AVG? #SQL #DataAnalytics #LearningInPublic #DataAnalystJourney #90DaysChallenge
To view or add a comment, sign in
-
-
📊 **SQL Cheat Sheet for Data Analysts** SQL is one of the most essential skills for anyone in Data Analytics. To make learning and revision easier, I’ve created a quick cheat sheet covering key concepts — from basics to advanced queries. This includes: ✔️ Data filtering & conditions ✔️ Aggregations & grouping ✔️ Joins and relationships ✔️ Window functions & advanced SQL Whether you're a beginner or brushing up your skills, this can be a handy quick reference. 💡 Save it for later and share it with others who are learning SQL! #SQL #DataAnalytics #DataScience #Learning #CareerGrowth #TechSkills #DataEngineer #Treading #LearningStage
To view or add a comment, sign in
-
-
Day 7: Mastering the Magic of SQL Window Functions! Today was a game-changer in my SQL journey. I dived deep into Window Functions, and I finally understand why they are a data analyst's best friend. Unlike standard aggregate functions, these allow me to look at individual rows while still calculating totals, averages, or rankings across a specific "window" of data. Key Takeaways from Today: PARTITION BY: This is like a "Group By" that doesn’t hide your rows. It breaks the data into logical chunks (e.g., grouping by Department) so the function can calculate values within those specific groups. OVER(): The "magic wand" that tells SQL, "Treat this as a window function." It defines exactly which rows the function should look at. RANK(): Perfect for finding the "Top N" items. It assigns a rank to each row based on a specific order. Window Frames (The "Rules"): I explored how to define moving windows using: ROWS PRECEDING: Looking back at previous rows. CURRENT ROW: Including the data right where we are. FOLLOWING: Peeking ahead. Why this matters? This is how we calculate Running Totals, Moving Averages, and Year-over-Year growth effortlessly. It’s the difference between seeing a flat table and seeing the story and trends within the data. Feeling more confident with every query! #SQL #DataAnalytics #LearningJourney #WomenInTech #DataScience #ContinuousLearning #SQLWindowFunctions
To view or add a comment, sign in
-
🚀 SQL Series – Part 8: Mastering Operators & Clauses Want to slice data like a pro? This post is all about mastering powerful SQL filtering techniques that every data analyst must know! 💡 Here’s what you’ll learn 👇 🔹 BETWEEN → Filter within a range (inclusive) 🔹 LIKE → Pattern matching using % & _ 🔹 IN / NOT IN → Check values in a set 🔹 Operators (AND, OR, NOT) → Combine conditions smartly 💡 BETWEEN = Range | LIKE = Pattern | IN = Set Master these, and you’ll transform raw data into meaningful insights effortlessly 📊 🔥 Whether you're preparing for interviews or working on real-world datasets — these are your go-to tools! #SQL #DataAnalytics #DataAnalyst #LearnSQL #SQLTips #DataScience #Analytics #TechSkills #Database #QueryOptimization #SQLQueries #LinkedInLearning
To view or add a comment, sign in
-
🚀 7-Day SQL Challenge – Day 3 (Leveling Up 📊) Today’s focus was on making data more meaningful using sorting, aggregation, and grouping. 🔹 Sorting Results (ORDER BY) Learned how to arrange data in ascending and descending order to quickly identify top or bottom values. 🔹 Aggregate Functions Worked with powerful functions like: ✔️ COUNT() – total records ✔️ SUM() – total value ✔️ AVG() – average ✔️ MAX() / MIN() – highest & lowest These functions help summarize large datasets into simple insights. 🔹 GROUP BY Clause Used to group data based on a column (like department-wise analysis). Makes it easier to analyze patterns across categories. 🔹 HAVING Clause Filters grouped data (unlike WHERE which filters rows). Very useful when working with aggregated results. 💡 Key Learning: Understanding how SQL processes queries step-by-step makes writing efficient queries much easier. 📌 SQL Execution Order: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY Day 3 done ✅ Feeling more confident with data analysis using SQL! #SQL #DataAnalytics #LearningJourney #7DayChallenge #DataAnalyst #SQLBasics
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
https://www.youtube.com/watch?v=mS_X3HNELDE