14_GROUPBY.pdf - CITS1402 Relational Database Management...

This preview shows page 1 - 13 out of 13 pages.

CITS1402 Relational Database Management Systems Video 14 — GROUP BY Gordon Royle Department of Mathematics & Statistics
Querying The basic SELECT statement that we are using is: SELECT <column_names> FROM <table_references> WHERE <row_conditions> GROUP BY <group_columns> HAVING <group_conditions> ORDER BY <sorting_columns> LIMIT <number_rows>
Grouping The GROUP BY statement is one of the most important we’ve seen. This statement groups together rows and then applies the summary/aggregate functions to each group separately. There is one output row for each group .
Summary for every year SELECT AVG (minutes) FROM MatchResult GROUP BY tournYear;
Code Dissection Rows are divided into groups according to the value of tournYear . Then SELECT AVG (minutes) is performed on each group separately .
Which year?
More than one column 2000 2000 2000 2000 2000 2019 2019 2019 2019 2019 2019

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture