Challenge

Project 2

Answer 1: The collections has been created and inserted data in attached file.

Note : please check attached file.

Answer2: Simple Queries to perform on ecommerce db.

use EcommerceDatabase

1.
db.customer.aggregate([{$group:{_id:"orderValue", Average_of_OrderValue:{$avg:"$orderValue"}}}])

2.
db.customer.find({}).sort({"orderValue":-1}).limit(10)

3.
db.orders.aggregate([{$group:{_id:"TotalCost", "Sum of Product Cost":{$sum:"$productCost"}}}])

4.
db.customer.aggregate([{$group:{_id:"$customer_city", count:{$sum:1}}}])

5.
db.getCollection("seller").aggregate([{ $lookup: { from: "customer", localField: "seller_city", foreignField: "customer_city", as: "rrder in same city" } }, { $sort: { order: -1 } }])

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.