Sha256: 3d285b7a90bb18c54289479fbb852b009f4cce74fbabf5942e5dedd5742a918f

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

#!/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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.9.0 examples/with.alf