Day 18/100 of #100DaysOfCode 💻 Short query. Clear logic. Clean result. 🎯 Customer Placing the Largest Number of Orders:- Find the customer who placed the most orders from the Orders table. GROUP BY to count orders per customer → ORDER BY COUNT DESC to rank them → LIMIT 1 to grab the top one. Done. ✅ 💡 The real insight here - LIMIT 1 is one of those small but powerful tools. Instead of writing a subquery or CTE to find the max, just sort and slice. Cleaner and faster. Sometimes the best query is the shortest one. 🧩 Not every day is a Hard problem grind, some days you just stay consistent, show up, and keep the streak alive. That matters too. 😄 #SQL #100DaysOfCode #LearningInPublic #DataAnalytics #Consistency #DevJourney #LeetCode
SQL Query: Find Customer with Most Orders
More Relevant Posts
-
39 problems solved. No shortcuts, no cramming. Just one problem a day — sometimes two if the first one clicks fast. Linked lists, backtracking, SQL queries, greedy scans. Each one a little uncomfortable at first, then suddenly obvious once it lands. That's kind of the whole point. Dashboard → https://lnkd.in/eWjTD6_P Repo → https://lnkd.in/ePM5inyX #LeetCode #CodingJourney #100DaysOfCode #BuildInPublic #SoftwareEngineering #ConsistencyOverMotivation #ProblemSolving
To view or add a comment, sign in
-
-
Day 16/100 of #100DaysOfCode 💻 Solved a Hard-level SQL problem today, but it didn't come easy. 🎯 Q. Trips & Users: Calculate the daily cancellation rate of taxi trips only for unbanned clients and drivers, within a specific date range. Honestly? I stared at this one for a while😅. I wrote the query, ran it, wrong output. Checked the logic, looked fine to me. Ran it again, still wrong. That frustrating loop where you know something's off but can't see what. Took a hint. And that's when it hit me🤦. I was only joining the Users table once. But you need a double JOIN, one for the client, one for the driver, because both must be unbanned for the trip to count. I was filtering one side and completely missing the other. One missing JOIN = entirely wrong cancellation rates across all three days. 💡 That's what makes this problem Hard, not the syntax, but the logic you almost overlook. Fixed it. Query ran clean. Used CASE WHEN inside ROUND(SUM(...)) to count cancellations per day and it finally made sense. Some days you need a hint. That's not failure, that's how you actually learn. 🧩 #SQL #100DaysOfCode #LearningInPublic #DataAnalytics #Consistency #DevJourney #LeetCode
To view or add a comment, sign in
-
-
Solving the SQL 50 challenge on LeetCode has been an exciting and confidence-boosting journey. Each problem pushed me to think deeper, optimize queries, and strengthen my understanding of SQL concepts. From basic queries to advanced topics like joins, aggregations, subqueries, and window functions — this journey was truly enriching 💡 📘 What’s in my notes/document? A structured study guide covering: All 50 problems with solutions Clear explanations for each query Key SQL concepts like SELECT, JOINs, Aggregations, Window Functions, and more Practical patterns and best practices for real-world scenarios Once you get a solid grip on fundamentals, problems labeled medium or even hard start feeling like easy. It’s all about consistency and practice. #SQL #LeetCode #DataEngineering #LearningJourney #sql50
To view or add a comment, sign in
-
🚀 Day 34/50 – #LeetCode Challenge Today’s problem: Product Price at a Given Date 📊 This one really tested my understanding of handling time-based data in SQL. 💡 Key Learning: When dealing with historical data, it's important to focus on the latest valid record before a given date — not just any record. 🔍 Approach I used: Consider all products Find the most recent price change on or before the target date (2019-08-16) If no change exists → use default price = 10 Used concepts like MAX(date), GROUP BY, and JOIN 🧠 What I improved today: Writing cleaner SQL queries Handling edge cases (no previous data) Thinking in terms of real-world data scenarios 🔥 Consistency is building confidence step by step. #Day34 #LeetCode #SQL #DataStructures #CodingJourney #Consistency #PlacementPreparation
To view or add a comment, sign in
-
-
🚀 High Performance SQL Query on LeetCode! Just solved “Customer Placing the Largest Number of Orders” and this one felt extra satisfying 😄 📊 Result: ✔️ Accepted ✅ (19/19 test cases passed) ✔️ Runtime: 427 ms ⚡ ✔️ Beats ~80% of submissions 🚀 💡 Problem Insight: The task was to find the customer who placed the maximum number of orders — a great use case of GROUP BY + aggregation + subquery. 🧠 My Approach: Counted orders per customer Compared it with the maximum order count using a subquery Returned the customer with the highest count SELECT customer_number FROM Orders GROUP BY customer_number HAVING COUNT(order_number) = ( SELECT MAX(order_count) FROM ( SELECT COUNT(order_number) AS order_count FROM Orders GROUP BY customer_number ) AS temp ); 🔥 Key Takeaway: Combining aggregation + nested queries helps solve ranking-type problems efficiently. Consistency is paying off — step by step improving both logic and performance 💪 #SQL #LeetCode #CodingJourney #Database #Learning #Tech #PlacementPreparation #Consistency
To view or add a comment, sign in
-
-
Day 21/100 of #100DaysOfCode 💻 Today's problem made me think in trees. 🌳 Tree Node:- Given a tree structure in a table, classify each node as Root, Inner, or Leaf. The logic: Root → has no parent (p_id IS NULL) Inner → appears as a parent of someone else Leaf → everything else I didn't get it right on the first try. 😅 My first attempt used "WHERE p_id = 1" inside the subquery, which hardcodes the root and breaks for any other tree structure. Wrong logic, wrong output. Then I stepped back and thought about it properly (Code is given in the image) 💡 The fix is instead of hardcoding, ask "does this node appear as a parent of anyone?" If yes → Inner. That's the real tree logic. Never hardcode what SQL can figure out dynamically. 🧩 Trial and error is part of the process. The wrong attempt taught me more than the right one. 😄 #SQL #100DaysOfCode #LearningInPublic #DataAnalytics #Consistency #DevJourney #LeetCode
To view or add a comment, sign in
-
-
🚀 Day 10/30 of My LeetCode Journey (SQL Focus) Double digits! Staying consistent and sharpening my SQL skills every day 📊🔥 🔹 **SQL Problem of the Day** 👉 *Employee Bonus* Given `Employee` and `Bonus` tables, write a query to report the name and bonus of employees who: • Have a bonus less than 1000 • OR did not receive any bonus 💡 *Key Concept:* LEFT JOIN + handling NULL values with conditional filtering. Understanding joins and NULL handling is making SQL much more intuitive now 💡 Day 10 done ✅ #LeetCode #30DaysChallenge #SQL #CodingJourney #Consistency #ProblemSolving #DataAnalytics #Learning
To view or add a comment, sign in
-
Day 8/50 – #SQLChallenge 🚀 Solved “Customer Who Visited but Did Not Make Any Transactions” problem on LeetCode. ✅ Approach: Used LEFT JOIN with NULL filtering ✅ Key Concept: Identifying unmatched records between tables 💡 Advanced Insight: Filtering with IS NULL after a LEFT JOIN is a common pattern to find missing relationships (anti-join behavior). This is widely used in real-world scenarios like identifying inactive users, failed transactions, or missing data entries. 🔍 Takeaway: Understanding how to detect absence of data is just as important as retrieving existing data — especially in analytics and backend systems. Consistency is turning into confidence 💪 #SQL #LeetCode #Database #Joins #CodingChallenge #ProblemSolving #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
🚀 Day 26 – 30 Days SQL LeetCode Challenge Today’s problem was simple but highlights an important real-world scenario 👀 📌 Today's Problem: Article Views I (LeetCode #1148) 🧠 Problem Statement: Find all authors who viewed at least one of their own articles. 💡 Key SQL Concepts Used: • DISTINCT • Filtering with conditions • Comparing columns within the same row 📚 What I Practiced Today: ✔ Comparing values within the same table ✔ Removing duplicates using DISTINCT ✔ Writing clean filtering queries 🔥 This pattern is useful in: • Detecting self-actions (self-purchases, self-views) • Fraud detection • User behavior analysis 🔗 GitHub Repository: https://lnkd.in/e8aV37dA #SQL #LeetCode #DataAnalytics #30DaysOfSQL #LearningInPublic
To view or add a comment, sign in
-
-
Day 87 of #100DaysOfCode Today I solved "Convert Sorted List to Binary Search Tree" on LeetCode using Two Pointers + Recursion. Key Idea: A sorted linked list can be converted into a height-balanced BST by always choosing the middle element as root. Approach: • Use slow & fast pointers to find the middle node • Middle node becomes the root • Left part → build left subtree • Right part → build right subtree Repeat this process recursively to construct the entire BST. Concepts Used: • Linked List • Binary Search Tree (BST) • Two Pointers (Slow & Fast) • Recursion Time Complexity: O(n log n) Space Complexity: O(log n) This problem helped me understand how to transform one data structure into another efficiently From lists → to trees… leveling up data structure mastery #Day87 #100DaysOfCode #LeetCode #BST #LinkedList #Recursion #Cpp #CodingJourney
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