Solved Hard SQL Problem with Double JOIN

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

  • graphical user interface

To view or add a comment, sign in

Explore content categories