May 2020
Beginner
564 pages
14h 9m
English
Using aggregate functions with GROUP BY can give you some interesting summarized results. We learned a bit about this already in Chapter 9, Working with Expressions. There are a couple of ways you can use aggregate functions in a query. One way requires a GROUP BY, while one doesn't.
If you want to summarize an entire table, you don't need to use GROUP BY, as shown in the following query:
USE lahmansbaseballdb; SELECT sum(AB) AS sum_at_batsFROM batting;
The results from running the previous query can be seen in the following table:
|
sum_at_bats |
|
'14922240' |
The previous result is the sum of all the at-bats (AB) for the entire table. That's ...
Read now
Unlock full access