- Ordering
Top-k queries: ORDER BY … DESC LIMIT k gives the k rows with the largest key; per-group maxima need Grouping instead. §
- Relational Algebra
| GROUP BY … HAVING … | Grouping group-by (VL05) | §
- Relational Model
The operations on tables (Relational Algebra: projection, selection, Cartesian Product, Join, Grouping) take tables and return a table, so they can be composed into query plans. SQL references columns by name cj; the formal operations r… §
- SQL Query Structure
| GROUP BY | 3 | partitions the surviving rows into groups and aggregates per group | Grouping | §
- Subquery
Typical use: per-group values back to rows. Grouping aggregates per column, so “for each year, the movie with the highest score” cannot be written with GROUP BY alone. Compute the aggregate per group in a subquery and join it back to the o… §
- VL05 – Joins and more SQL
The slide uses j for both the aggregate index and the “for all” quantifier; here i is used for the latter. See Grouping. §
Grouping — formal group-by operation, HAVING, hash-map implementation and cost estimate §
- SQL and Query Planning
Grouping — group-by with aggregation functions and HAVING §
When SQL needs more than one clause. “Per group, a value” → Grouping; “per group, the row with the extreme value” (argmax) cannot be done by GROUP BY alone and needs a Subquery joined back to the table. WHERE filters rows before grouping,… §
- SPARQL AggregationADIS
partitions the rows of R into groups with equal values of (g1,…,gm) and returns one row per group. It contains the values of the grouping variables and, for each (AGG(?x) AS ?y), the aggregate function AGG (COUNT, SUM, AVG, …)… §
- Advanced SPARQLADIS
| GROUP BY + aggregate | one row per group | grouping variables + aggregates | GROUP BY (Grouping) | §