by
by, table creation
The by
statement creates a table by grouping the lines of the target vector into group of identical values.
table Orders = with
[| as Pid, as OrderDate, as Quantity |]
[| "apple", date(2022, 9, 13), 3 |]
[| "orange", date(2022, 9, 14), 2 |]
[| "apple", date(2022, 9, 15), 7 |]
[| "orange", date(2022, 9, 15), 2 |]
[| "apple", date(2022, 9, 16), 7 |]
table Products[product] = by Orders.Pid
show table "Products" a1b2 with
product
sum(Orders.Quantity) into Products
The statement also operates if a tuple is provided.
table Orders = with
[| as Pid, as OrderDate, as Quantity |]
[| "apple", date(2022, 9, 13), 3 |]
[| "orange", date(2022, 9, 14), 2 |]
[| "apple", date(2022, 9, 15), 7 |]
[| "orange", date(2022, 9, 15), 2 |]
[| "apple", date(2022, 9, 16), 7 |]
table Sales[tu] = by [Orders.Pid, Orders.OrderDate]
Sales.Product, Sales.OrderDate = tu
show table "Sales" a1b5 with
Sales.Product
Sales.OrderDate
sum(Orders.Quantity) into Sales