#!/usr/bin/env alf # Compute the total qty supplied in each country together with the subset # of products shipped there. Only consider suppliers that have a status # greater than 10, however. (summarize \ (join \ (join (restrict :suppliers, lambda{ status > 10 }), :supplies), :cities), [:country], :which => Agg::group(:pid), :total => Agg::sum{ qty }) # Another equivalent way to write it with( :kept_suppliers => (restrict :suppliers, lambda{ status > 10 }), :with_countries => (join :kept_suppliers, :cities), :supplying => (join :with_countries, :supplies) ) do (summarize :supplying, [:country], :which => Agg::group(:pid), :total => Agg::sum{ qty }) end