Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAquib Javed
8,289 PointsWhat is the specific usage of the group by clause in SQL?
From W3 and some other search results, what I learned is, 'group by' summarizes an output, as in instead of showing a number of different results, it shows them in one particular output. What I don't understand is, when is it actually necessary to use the clause?
1 Answer
Product Team
6,835 PointsI'm fairly new to SQL, but my understanding is that it "rolls-up" or merges rows. For example, you have the following rows:
Country | Points
- USA 12
- Canada 6
- USA 18
Group By country would roll this up to
Country | Points
- USA 30
- Canada 6
I'm guessing I'm describing this poorly, but it is how I use it.