# How many cars of each manufacturer are there in the catalog

from nested import product_db
from pythonql.helpers import print_table

res = [ select (man, len(p) as n_models)
        for p in product_db

        # As we drill into the manufacturer, we try to
        # extract the company object. If we fail, an exception is
        # thrown and we return the original object (which should be a
        # string )

        let man = try p['manufacturer']['company'] except p['manufacturer']
        group by man ]

print_table(res)

play
# How many cars of each manufacturer are there in the catalog

from nested import product_db
from pythonql.helpers import print_table

res = [ select (man, len(p) as n_models)
        for p in product_db

        # As we drill into the manufacturer, we try to
        # extract the company object. If we fail, an exception is
        # thrown and we return the original object (which should be a
        # string )

        let man = try p['manufacturer']['company'] except p['manufacturer']
        group by man ]

print_table(res)

play