SQL Learning: GROUP BY, HAVING, and Subqueries with Match ID

Today’s SQL learning focused on solving problem using GROUP BY, HAVING, and subqueries. Problem Statement: Find all matches where the total number of bowled dismissals was greater than or equal to 2 in an over, and this happened more than once in the same match. SQL Query: select match_id from ( select MatcH_id as match_id, Innings_No, Over_id, sum(bowled) as total_bowled from ball_by_ball group by MatcH_id, Innings_No, Over_id ) t where total_bowled >= 2 group by match_id having count(*) >= 2 order by match_id; Key Learnings: ✅ Used subquery to calculate bowled dismissals per over ✅ Applied WHERE to filter overs with 2+ bowled dismissals ✅ Used HAVING COUNT(*) >= 2 to identify matches where it happened multiple times ✅ Improved understanding of multi-level aggregation in SQL 🔗 Project Notebook: https://lnkd.in/g_wxP6GC 📂 Sample Dataset: https://lnkd.in/gB3jZHht #SQL #DataAnalytics #DataScience #LearningJourney #100DaysOfCode #LinkedInLearning #Analytics #Database

To view or add a comment, sign in

Explore content categories