Hey guys, below is a screenshot of my solution to the challenge "each country’s best customer’ under “Building and Organizing Complex Queries.” Quite different from the solution suggested by DQ but it worked! I prefer the way I solved it since is much shorter but I’m new to coding so I’m just hoping for feedback on it. Thanks!
Screen link: Learn data science with Python and R projects
On my first attempt to solve this challenge I had a similar query, but then I looked through other threads on this mission and realized why my solution was not correct although giving the same results.
In short, the answer would be: you can´t leave any non-aggregated column outside the
GROUP BY clause.
For more explanation, please, check this great step-by-step explanation of why it is important to include all the non-aggregated columns inside the
GROUP BY and a couple of other threads with similar questions:
- Solution for 190-8 "Challenge: Each Country's Best Customer" seems overly complicated? - #2 by Bruno
- 190-8 Feedback - Building and Organizing Complex Queries - Challenge
Thank you, Ksenia.
The oldest of these answers was eventually turned into this blog post.
Great! Everything is gathered together in one place
It would have saved me some time if I had seen it when was struggling with this challenge
Absolutely truth, Cause why would Dataquest teach as the most simplest technique but end up recommending an answer which is contrary to the simplicity they have been expecting from us.