🐿️
10

Vent: My first solo SQL query took 3 hours and I'm glad it failed

Last Tuesday I tried to write a query to pull sales data for our small shop in Boise. I was so proud of myself for finally learning joins. Then I ran it and it returned 40,000 rows when we only have 300 customers. My boss looked at the screen and said "you joined on the wrong key." I spent 2 more hours tracing it, and it turned out I used the order ID instead of customer ID. Everyone online says start with CTEs and window functions, but honestly I think beginners should break things like this on purpose first. Has anyone else had a horrific first query that taught them more than any tutorial?
1 comments

Log in to join the discussion

Log In
1 Comment
taylor.betty
That 40k rows thing made me laugh cause I did almost the same thing with a customer list in Portland, pulled 12k records and my manager just sighed and walked away. I get the value of breaking stuff, but I think tutorials exist so you dont waste a whole afternoon on a mistake that one explainer video couldve saved you from. The real lesson isnt the wrong join, its learning to check your row counts before you show anyone, that stuck with me way more than any CTE. Breaking things on purpose sounds fun but in a real job that clock is ticking, so maybe break things in a sandbox database instead of production.
2