Chapter 4: Advanced CRUD Operations Lab 1: Logic Operators

Hey guys,

I have the following exercise:

How many zips in the sample_training.zips dataset are neither over-populated nor under-populated?

In this case, we consider population of more than 1,000,000 to be over- populated and less than 5,000 to be under-populated.

I tried following queries:
<deleted, reason: potential answer>

All return 11191, which apparently is a wrong answer.
Could somebody tell me why?

I also ran the commands before and after:

Before solving this exercise, make sure to undo some of the changes that we made to the zips collection earlier in the course by running the following command:

db.zips.updateMany({ “city”: “HUDSON” }, { “$inc”: { “pop”: -10 } })


Hi there @Vali_Mandeal

did you run the command
db.zips.updateMany({ “city”: “HUDSON” }, { “$inc”: { “pop”: -10 } })

first before running your
<deleted, reason: potential answer>

I was stuck on this one too… First you need to run the command on the collection like stated above… Second I did the same mistake… Read it really carefully, you want those cities that are NOT under 5000 or NOT over 1000000.

I don’t want to give the lab away, but if you cannot figure it out… give me a holler!!

Have fun!!

1 Like

Hi David, well, you are very close to the answer, but it looks like some of you data has gone sideways(population of some documents might got modified while performing other labs), I would recommend you to do one of the below two things:
1.) Drop all the sample databases in your cluster and load the sample data again
2.) Create a new project in your Atlas organization and you can again load a fresh sample data on your cluster
And then try again on the refreshed sample data. I hope it helps.
Thanks. Regards.
Sourabh Bagrecha,
Curriculum Services Engineer.

I was trying to nudge and still not give the answer. I solved the problem by running the command for the collection and running this query:

That returns the right answer.

Hi David, AFAIK both the command should return the same result, but I am glad that you got your lab completed. Good luck.

Thanks. Regards.
Sourabh Bagrecha,
Curriculum Services Engineer.