SQL Group By
How to Program with Java Podcast - En podcast af Trevor Page: Java Guru | Programmer | Teacher
Kategorier:
After having talked about all the SQL Aggregate functions, there’s one more topic that goes hand in hand with what we’ve already learned… The group by keyword. This particular keyword allows us to take a bunch of data and mash it all together into matching groups and then perform aggregate functions on those groups (like sum and avg). You might ask yourself why you’d want to “mash together” a bunch of data. The answer to this is best explained with an example, but let me try to put it in regular words before we jump into our example. Grouping data together allows us to look at aggregate data in relation to unique piece of data (or rows), a typical use case would be to group all the matching data together so you can get a count of the number of occurrences of specific data. An example related to grouping and counting could be a presidential election, you’ll have all the votes in a database and you’ll want to group that data together to get the total votes for each unique candidate... For more info, check out the show notes via http://howtoprogramwithjava.com/session48