1 point by yimingchen 5 days ago | flag | 1 comment
yimingchen 5 days ago | flag

Samely, the table in the section Filtered Aggregation

Pid Sold
apple 10
orange -3
banana -2

should have been

Pid Sold
apple 3
orange -2
banana -3


table Orders = with
  [| as Pid, as OrderDate, as Quantity |]
  [| "apple",  date(2020, 4, 15), 3 |]
  [| "apple",  date(2020, 4, 16), 7 |]
  [| "orange", date(2020, 4, 16), 2 |]
 
table Products = with
  [| as Pid, as MyDefault |]
  [| "apple",  -1 |]
  [| "orange", -2 |]
  [| "banana", -3 |]

Products.Sold = sum(Orders.Quantity)
  when (Orders.OrderDate < date(2020, 4, 16))
  default Products.MyDefault
  by Orders.Pid
  at Products.Pid
 
show table "Products" with
  Products.Pid
  Products.Sold