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: