🚀 Day 44 of My SQL Learning Journey Today I solved a SQL problem involving aggregation and distinct counting 🔥 🔹 Problem: Find number of unique leads and partners per day 🔗 Problem Link: https://lnkd.in/gXnubrbd 🔹 Solution: SELECT date_id, make_name, COUNT(DISTINCT lead_id) AS unique_leads, COUNT(DISTINCT partner_id) AS unique_partners FROM DailySales GROUP BY date_id, make_name; 🔹 Key Learning: Using multiple COUNT(DISTINCT) Grouping by multiple columns Real-world reporting queries 💡 SQL helps transform raw data into meaningful insights! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #CodingJourney #DataAnalytics
SQL Learning Journey: Aggregation and Distinct Counting
More Relevant Posts
-
🚀 Day 40 of My SQL Learning Journey Today I worked on a SQL problem involving aggregation and string manipulation 🔥 🔹 Problem: Group sold products by date and list them in sorted order 🔗 Problem Link: https://lnkd.in/gp6qVmNt 🔹 Solution: SELECT sell_date, COUNT(DISTINCT product) AS num_sold, GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR ',') AS products FROM Activities GROUP BY sell_date; 🔹 Key Learning: Using COUNT(DISTINCT) for unique values Combining rows using GROUP_CONCAT() Sorting values inside aggregation 💡 SQL can generate clean reports directly from raw data! Consistency continues 🚀 #SQL #LeetCode #90DaysOfCode #DataAnalytics #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 42/100 – LeetCode SQL Practice ✅ Problem Solved: Average Time of Process per Machine 💡 My Approach: Each process has a start and end timestamp I joined the table with itself to match: 👉 start row with corresponding end row (same machine_id & process_id) Then calculated: 👉 Time = end - start Finally: 👉 Took average time per machine using AVG() 👉 Used ROUND(..., 3) to format output to 3 decimal places 🧠 What I Learned Today: How to use SELF JOIN in SQL Understanding how to pair related rows (start & end) Using aggregate functions like AVG() Importance of data formatting using ROUND Writing clean queries with GROUP BY 📈 Key Takeaway: “Break the problem → pair related data → compute → aggregate.” #Day42 #100DaysOfCode #LeetCodeSQL #SQL #DataAnalytics #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 2 of My SQL Learning Journey Today I learned about the WHERE clause in SQL. 👉 WHERE is used to filter data based on specific conditions. Basic syntax: SELECT column_name FROM table_name WHERE condition; ✔ Helps in retrieving only the required data ✔ Can be used with operators like =, >, <, AND, OR 💡 Learning WHERE made me realize how powerful SQL is when working with large datasets. Excited to keep improving! 🔥 Next: INSERT statement 👀 #SQL #LearningJourney #Beginner #DataAnalytics #Day2 #LearnInPublic
To view or add a comment, sign in
-
-
🚀 Day 19/50 – LeetCode SQL Challenge (Queries Quality & Percentage) Today’s problem focused on analyzing query performance by calculating quality and identifying poor queries using SQL. 📊 Key Concepts Used: • Aggregation (AVG, COUNT) • CASE WHEN (conditional logic) • Ratio calculation (rating / position) • ROUND() function 💡 Approach: Calculated query quality using AVG(rating / position) Used CASE WHEN to identify poor queries (rating < 3) Computed poor query percentage using average of conditional values Rounded both metrics to 2 decimal places for better readability 👉 Learned how to convert conditions into numerical values (0/1) and use AVG to directly calculate percentages. 🧠 Key Learning: AVG of 0/1 can be used to calculate percentage efficiently Combining aggregation with conditional logic simplifies complex problems Clean formatting (ROUND) makes results more professional 📈 Consistency in practice is building stronger SQL fundamentals every day #SQL #DataAnalytics #DataAnalyst #LearningInPublic #30DaysChallenge #SQLPractice #Analytics #CareerGrowth #Consistency #DataScience
To view or add a comment, sign in
-
-
🚀 Day 18/50 – LeetCode SQL Challenge (Percentage of Users Attending a Contest) Today’s problem focused on calculating the percentage of users registered in each contest using SQL. 📊 Key Concepts Used: • GROUP BY • COUNT() • Subquery (total users calculation) • ROUND() function 💡 Approach: Calculated total number of users from Users table Grouped data by contest_id Counted number of users in each contest using COUNT(user_id) Calculated percentage using (count / total_users) * 100 Used ROUND to format output to 2 decimal places 👉 Learned how important it is to use subqueries correctly when calculating overall percentages. 🧠 Key Learning: Understanding total vs grouped data is crucial for percentage problems Using 100.0 ensures correct decimal calculation Aggregation with proper logic gives accurate insights 📈 Consistency is the key to mastering SQL #SQL #DataAnalytics #DataAnalyst #LearningInPublic #30DaysChallenge #SQLPractice #Analytics #CareerGrowth #Consistency #DataScience
To view or add a comment, sign in
-
-
❄️ LeetCode Daily Challenge 📅 Day 40 of 50 Days SQL Challenge Today’s challenge focused on subscription funnel analysis — a common real-world business analytics use case 📈 📌 Problem: Analyze Subscription Conversion 🔗Problem Link: https://lnkd.in/gSEZWxJb 💡 Problem Breakdown: Identify users who converted from free trial to paid subscription: ✔ Find users who moved from free_trial to paid ✔ Calculate average daily activity duration during free trial ✔ Calculate average daily activity duration during paid period ✔ Round averages to 2 decimal places 40 days of consistent SQL practice completed ✅ Daily practice is turning concepts into intuition 💪 Let’s grow one query at a time 🚀 💬 How would you approach this? Single query with conditional aggregation or separate CTEs? Drop your thoughts below 👇 #LeetCode #SQL #DataEngineering #AzureDataEngineer #ProductAnalytics #SQLPractice #LearningInPublic #50DaysChallenge #DataAnalytics
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on LeetCode — Day 46 of my SQL Journey 💪 Customers don’t just buy products… They buy patterns together 🛒 Today’s problem was about finding product categories that are frequently bought together — The logic behind “you might also like.” The approach: • Mapped each user to their purchased categories • Used a self-join to create category pairs • Applied category1 < category2 to avoid duplicates • Counted shared users per pair and filtered meaningful ones What I practised: • Self joins to relate data within the same dataset • Using DISTINCT for accurate counting • Applying GROUP BY with HAVING • Translating real behaviour into SQL logic What stood out — Recommendations aren’t random… They’re built on repeated patterns. When enough users repeat the same combination, It becomes a signal. That’s where the real insight lies. SQL doesn’t just store transactions. It uncovers relationships between them. Consistent learning, one query at a time 🚀 #SQL #LeetCode #DataAnalytics #LearningInPublic #SQLPractice
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
-
🚀 𝗗𝗮𝘆 𝟱𝟴 𝗼𝗳 𝗦𝗤𝗟 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 – 𝗥𝗼𝘄 𝗘𝘅𝗽𝗮𝗻𝘀𝗶𝗼𝗻 𝘂𝘀𝗶𝗻𝗴 𝗥𝗲𝗰𝘂𝗿𝘀𝗶𝘃𝗲 𝗖𝗧𝗘 Today’s SQL challenge focused on a classic yet insightful problem: expanding rows based on their own values. 📌 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗦𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁 Given a table of numbers, each value n represents how many times it should appear in the output. 👉 Example: 1 → appears 1 time 2 → appears 2 times 3 → appears 3 times 💡 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: I used a Recursive CTE to iteratively build the result set. Starting with the base value, I kept adding rows until each number was repeated the required number of times. This approach felt intuitive almost like translating a loop directly into SQL #Day57 #SQL #DataEngineering #RecursiveCTE #LearningInPublic #ProductAnalytics #Zepto
To view or add a comment, sign in
-
-
☀️Hello mates!! Day 02 solving the SQL 50 LeetCode (02/50) Today's problem is #584: "Find Customer Refree"👨💻 This is an Easy-level problem that focuses on filtering data using SQL condition. I used the WHERE clause, along with proper NULL handling, and it successfully passed all the test case✅️ How my solution Works: ->The WHERE clause is used to select Customer whose refree_id is not equal to 2. ->The OR condition ensure that Customer with no referee (NULL values) are also included in the result. ->Since the problem doesn't require any joins or aggregations, the query stays simple, clean and easy to understand. ->This approach reflect real-world SQL querying practices used in Data Analytics and Data Engineering task. Database Used:MYSQL See you all tomorrow with another exciting LeetCode problem #LeetCode #SQL50 #SQLQuery #DataAnalytics #Database #Coding #SQLPractice #Coding
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