Simple GROUP BY Query
SELECT category_id, AVG(list_price)
GROUP BY category_id
- Set the bike database to be the default
SELECT category_id, AVG(list_price):
- Select the category_id from the base table
- Calculate the Average of the list price for all rows in the table
- Product is the base table from which data will be returned
GROUP BY category_id:
- Instead of returning a single value that is the average of all list_price items in the product table, return an average list_price for each category
- Without the GROUP BY clause, we see from our first example only a single row is returned with an average list_price of 1520.591402.
- With the GROUP BY clause, we return an average for each category_id.
End-of-Chapter Survey: How would you rate the overall quality of this chapter?
- Very Low Quality
- Low Quality
- Moderate Quality
- High Quality
- Very High Quality