Lab 1: Logic Operators , both queries give different results

Hello team,

I am wondering why I am getting two different results for following queries.

db.zips.find({ “pop”: { “$gte”: 5000, “$lte”: 1000000 }}).count()

this query gives me the correct result 11193 but in my shell is used the $nor operator and it leads to result 11195 which is wrong. Where does the difference come from?

db.zips.find({ “$nor”: [ { “pop”: { “$lt”:5000 } },
{ “pop”: { “$gt”: 1000000 } } ] } ).count()

Thanks you

Hi :wave: @Mieke_Mehrtens,

Welcome to MongoDB Community forums!

I think you have altered the sample data set in your Atlas cluster.

I ran both the queries and got the same result.

Please let us know if you have any other questions!

Regards,
Kushagra

Hi @Kushagra_Kesav

thanks for your help. How can I undo any changes?

Best,
Mieke

Hi @Mieke_Mehrtens, follow the steps mentioned in the Question 5 of this FAQ post to reset your collection data:

If you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
MongoDB

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.