Untitled
unknown
plain_text
5 months ago
472 B
4
Indexable
pipeline = [ { '$lookup': { 'from': 'customers', 'localField': 'customer_id', 'foreignField': 'customer_id', 'as': 'customer_info' } }, { '$unwind': '$customer_info' }, { '$group': { '_id': '$customer_info.location', 'totalRevenue': {'$sum': '$price'} } } ] result = list(orders.aggregate(pipeline)) for doc in result: print(doc)
Editor is loading...
Leave a Comment