From b36213a58db54e030addfcf976bc713149e2725d Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sat, 9 Nov 2024 17:25:42 +0530 Subject: [PATCH] Fixed query 2 --- Practical/Assignment-B2/Queries-B2.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Practical/Assignment-B2/Queries-B2.md b/Practical/Assignment-B2/Queries-B2.md index e808da1..653a2bb 100755 --- a/Practical/Assignment-B2/Queries-B2.md +++ b/Practical/Assignment-B2/Queries-B2.md @@ -27,17 +27,20 @@ db.Employee.aggregate([ 2. Find Employee with Total Salary for Each City with Designation "Developer": ```mongodb db.Employee.aggregate([ - { - $match: { Designation: "Developer" } - }, - { - $group: { - _id: { $arrayElemAt: ["$Address.PAddr", 0] }, - TotalSalary: { $sum: "$Salary" } - } + { + $match: { + Designation: "Developer" } + }, + { + $group: { + _id: "$Address.PAddr", + Total: { $sum: "$Salary" } + } + } ]) + ``` 3. Find Total Salary of Employee with Designation "Tester" for Each Company: