TIP: whenever you open a bracket/parenthesis always immediately close it without writing anything in first. Open the bracket > then close it> then go back to the closed bracket/parenthesis and write in it. in that way you wont confuse with how many brackets you need to close after u write everything and in the video thats why there was an error in the first example because there was one parenthesis missing.
To find the entry of a department ID that occurs more than once in MongoDB, you can use the aggregation framework and the $group operator. Here's an example query: db.collection_name.aggregate([ { $group: { _id: "$department_id", count: { $sum: 1 } } }, { $match: { count: { $gt: 1 } } } In this query, we first group the documents in the collection by the department_id field using the $group operator. We create a new field called count using the $sum operator to count the number of documents in each group. Then, we use the $match operator to filter out the groups where the count is less than or equal to 1. The resulting documents will have the _id field equal to the department_id and the count field equal to the number of times that department_id appears in the collection.
This is an explanation given like a amateur. I appreciate the efforts though. You did lots of syntax issue and you did not cover how you fixed it. Well professional like me can take advantage over internet but think about beginners. And you missed lots of other serious points.
TIP:
whenever you open a bracket/parenthesis always immediately close it without writing anything in first. Open the bracket > then close it> then go back to the closed bracket/parenthesis and write in it. in that way you wont confuse with how many brackets you need to close after u write everything and in the video thats why there was an error in the first example because there was one parenthesis missing.
Underrated channel...he deserves million..very good explanation man..
We are glad that you have enjoyed your learning experience with us : )
Nice explanation... it's very useful to everyone ☺️
my man. thanks
thanks you very much dude
Good detail, thanks men..!
7:08
where can we get the data that you are using?
Super Class
7:51 7:08
Above code for list of department id @13:02 the output i m getting is { _id:department_id } not the whole list of ids..what m i doing wrong?
Brother,iam getting repeated 2 times output for match command
Hi, how do you find the entry of department ID that occurs more than once
To find the entry of a department ID that occurs more than once in MongoDB, you can use the aggregation framework and the $group operator. Here's an example query:
db.collection_name.aggregate([
{
$group: {
_id: "$department_id",
count: { $sum: 1 }
}
},
{
$match: {
count: { $gt: 1 }
}
}
In this query, we first group the documents in the collection by the department_id field using the $group operator. We create a new field called count using the $sum operator to count the number of documents in each group.
Then, we use the $match operator to filter out the groups where the count is less than or equal to 1. The resulting documents will have the _id field equal to the department_id and the count field equal to the number of times that department_id appears in the collection.
This is an explanation given like a amateur. I appreciate the efforts though. You did lots of syntax issue and you did not cover how you fixed it. Well professional like me can take advantage over internet but think about beginners. And you missed lots of other serious points.
what're u doing here?
@@youssef944 wasted time, still wasting time. RUclips algorithm made me do it. Dont call me out. Do something meaningfull.
@@krish3d385 What