Database

db={"Products":[{"Product_ID":1,"Product_Name":"G.Skill Ripjaws V Series","Description":"Speed:DDR4-3000,Type:288-pin DIMM,CAS:15Module:8x8GBSize:64GB","Standard_Cost":450,"List_Price":640,"Category_ID":5},{"Product_ID":2,"Product_Name":"Intel Xeon E5-2697 V4","Description":"Speed:2.3GHz,Cores:18,TDP:145W","Standard_Cost":2144,"List_Price":2554,"Category_ID":1},{"Product_ID":3,"Product_Name":"Corsair CB-9060011-WW","Description":"Chipset:GeForce GTX 1080 Ti,Memory:11GBCore Clock:1.57GHz","Standard_Cost":573,"List_Price":799,"Category_ID":2},{"Product_ID":4,"Product_Name":"AMD 100-505989","Description":"Chipset:FirePro W9100,Memory:32GBCore Clock:930MHz","Standard_Cost":2128,"List_Price":2699,"Category_ID":2},{"Product_ID":5,"Product_Name":"PNY VCQK6000-PB","Description":"Chipset:Quadro K6000,Memory:12GBCore Clock:902MHz","Standard_Cost":1740,"List_Price":2290,"Category_ID":2},{"Product_ID":6,"Product_Name":"Zotac ZT-P10810A-10P","Description":"Chipset:GeForce GTX 1080 Ti,Memory:11GBCore Clock:1.48GHz","Standard_Cost":702,"List_Price":849,"Category_ID":2},{"Product_ID":7,"Product_Name":"G.Skill Ripjaws V Series","Description":"Speed:DDR4-3200,Type:288-pin DIMM,CAS:15Module:8x8GBSize:64GB","Standard_Cost":602,"List_Price":680,"Category_ID":5},{"Product_ID":8,"Product_Name":"Intel Xeon E5-1650 V4","Description":"Speed:3.6GHz,Cores:6,TDP:140W","Standard_Cost":535,"List_Price":601,"Category_ID":1},{"Product_ID":9,"Product_Name":"Intel Xeon E5-2640 V4","Description":"Speed:2.4GHz,Cores:10,TDP:90W","Standard_Cost":738,"List_Price":899,"Category_ID":1},{"Product_ID":10,"Product_Name":"Crucial","Description":"Speed:DDR4-2133,Type:288-pin DIMM,CAS:15Module:2x16GBSize:32GB","Standard_Cost":580,"List_Price":811,"Category_ID":5},{"Product_ID":11,"Product_Name":"PNY VCQP5000-PB","Description":"Chipset:Quadro P5000,Memory:16GBCore Clock:1.61GHz","Standard_Cost":1602,"List_Price":2015,"Category_ID":2},{"Product_ID":12,"Product_Name":"Gigabyte GV-N108TAORUSX W-11GD","Description":"Chipset:GeForce GTX 1080 Ti,Memory:11GBCore Clock:1.63GHz","Standard_Cost":596,"List_Price":824,"Category_ID":2},{"Product_ID":13,"Product_Name":"G.Skill Ripjaws V Series","Description":"Speed:DDR4-3333,Type:288-pin DIMM,CAS:16Module:4x16GBSize:64GB","Standard_Cost":618,"List_Price":704,"Category_ID":5},{"Product_ID":14,"Product_Name":"G.Skill Ripjaws V Series","Description":"Speed:DDR4-3333,Type:288-pin DIMM,CAS:16Module:4x16GBSize:64GB","Standard_Cost":633,"List_Price":704,"Category_ID":5},{"Product_ID":15,"Product_Name":"G.Skill Trident Z","Description":"Speed:DDR4-3466,Type:288-pin DIMM,CAS:16Module:4x16GBSize:64GB","Standard_Cost":601,"List_Price":725,"Category_ID":5},{"Product_ID":16,"Product_Name":"Intel Core i7-6900K","Description":"Speed:3.2GHz,Cores:8,TDP:140W","Standard_Cost":792,"List_Price":889,"Category_ID":1},{"Product_ID":17,"Product_Name":"Corsair Vengeance LPX","Description":"Speed:DDR4-3333,Type:288-pin DIMM,CAS:15Module:4x16GBSize:64GB","Standard_Cost":595,"List_Price":699,"Category_ID":5},],"ProductSold":[{"Product_ID":1,"TotalQuantity":457},{"Product_ID":2,"TotalQuantity":229},{"Product_ID":3,"TotalQuantity":147},{"Product_ID":4,"TotalQuantity":441},{"Product_ID":5,"TotalQuantity":109},{"Product_ID":6,"TotalQuantity":245}],"ProductStock":[{"Product_ID":3,"Product_Name":"Corsair CB-9060011-WW","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":106},{"Product_ID":4,"Product_Name":"AMD 100-505989","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":106},{"Product_ID":5,"Product_Name":"PNY VCQK6000-PB","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":106},{"Product_ID":6,"Product_Name":"Zotac ZT-P10810A-10P","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":107},{"Product_ID":11,"Product_Name":"PNY VCQP5000-PB","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":108},{"Product_ID":12,"Product_Name":"Gigabyte GV-N108TAORUSX W-11GD","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":108},{"Product_ID":80,"Product_Name":"Intel Xeon E5-1650 V3","Warehouse_ID":1,"Warehouse_Name":"Southlake, Texas","Location_ID":5,"Address":"2014 Jabberwocky Rd","Country_name":"United States of America","region_name":"Americas","Total_Quantity":125},]}

Query

db.Products.aggregate([{$lookup:{from:"ProductSold",localField:"Product_ID",foreignField:"Product_ID",as:"sold"}},{$match:{sold:{$size:0}}},{$lookup:{from:"ProductStock",localField:"Product_ID",foreignField:"Product_ID",as:"stockData"}},{$set:{Total_Stock:{$sum:"$stockData.Total_Quantity"}}},{$sort:{Total_Stock:-1/** Sort in descending order of Total_Stock*/}}])

Result