Chapter 4 : Quiz 1: Logic Operators

The question in this quiz reads:

How many businesses in the sample_training.inspections dataset have the inspection result “Out of Business” and belong to the “Home Improvement Contractor - 100” sector?

The question is about usage of $and logical operator because we need to find the result which has the given inspection result as well as belong to the given sector. The query should be:
db.inspections.find({"result": "Out of Business"}, {"sector": "Home Improvement Contractor - 100"}).count()
resulting in the correct answer as 7038.
However, the given answer is 4, which is obtained using the $or operator.


does not find all documents result “Out of Business” AND belong to the “Home Improvement Contractor - 100”. Because the query part is {“result”: “Out of Business”} because the closing braces ends the first parameter. The second parameter is take as the projection parameter.

I do not think that is possible that A or B gives a smaller result set than A and B.

You are right. Thanks for pointing out the syntax error. :+1:

7038 incorrect answer

Please read the thread completely. 7038 is not the correct answer and the reasons are given.

Hi @sampath_sandaruwan,

Welcome to the MongoDB Community Forums!!

I hope that you were able to resolve your problem, if not kindly let us know by replying to this thread, we would be happy to help. :sparkles:

Kushagra Kesav,
Curriculum Services Engineer

correct answer is : 4

Yes it is, as indicated in the very first post of this thread.

1 Like