Relation:Tutorial 6

Projection to aggregate

When you project, you normally reduce also the number of the rows. For the visible columns, other columns share the rows. You may aggregate the other columns to get the count, sum or average of it.
We reuse the table films.csv
Look at the code on the right and compare with the result.

Show the number of titles by director

director film_count
Godard 3
Truffaut 2
Varda 2
von Trotta 1
Kluge 1

You just need to add an aggregator to the column count sum avg etc.
This creates a new columns which will be automatically called film_count.
We can reuse the result to create a global average.

Show the average number of titles by director

film_count_avg
1.8

Go to Tutorial 7

' ===Projection to aggregate===

' When you project, you normally reduce also the number of the rows. For the visible columns, other columns share the rows. You may aggregate the other columns to get the count, sum or average of it.

' We reuse the table [[Media:films.csv]]

' Look at the code on the right and compare with the result.

' '''''Show the number of titles by director'''''

read "films.csv"

project director, film count

print

' You just need to add an aggregator to the column '''count''' '''sum''' '''avg''' etc.

' This creates a new columns which will be automatically called film_count.

' We can reuse the result to create a global average.

' '''''Show the average number of titles by director'''''

project film_count avg

print

' Go to [[Tutorial 7]]