MongoDB Questions and Answers – Pipeline Operators – 2

«
»

This set of MongoDB Questions for entrance exams focuses on “Pipeline Operators – 2”.

1. $sum is an accumulator operator available only in the _______ stage.
a) $group
b) $sets
c) $accumulator
d) None of the mentioned
View Answer

Answer: a
Explanation: $sum calculates and returns the sum of all the numeric values.

advertisement

2. Point out the wrong statement.
a) $avg is an accumulator operator available only in the $group stage
b) $sum accumulator can be used to compute the total amount and count for each group of documents
c) $avg ignores numeric values
d) All of the mentioned
View Answer

Answer: c
Explanation: $avg returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key.

3. Which of the following ignores non numeric values?
a) $order
b) $sum
c) $asc
d) None of the mentioned
View Answer

Answer: b
Explanation: $sum returns a sum for each group. Ignores non-numeric values.

advertisement
advertisement

4. When using $first in a $group stage, the $group stage should follow a _______ stage to have the input documents in a defined order.
a) $order
b) $sort
c) $asc
d) None of the mentioned
View Answer

Answer: b
Explanation: $sort takes a document that specifies the field(s) to sort by and the respective sort order.

5. Which of the following returns the value that results from applying an expression to the last document?
a) $end
b) $last
c) $max
d) All of the mentioned
View Answer

Answer: b
Explanation: $last has the following syntax: { $last: <expression> }.

advertisement

6. __________ returns the highest value from the group of values in documents.
a) $end
b) $last
c) $max
d) $maximum
View Answer

Answer: c
Explanation: $max returns the highest value that results from applying an expression to each document in a group of documents that share the same group by key.

7. Which of the following is syntax for calculating minimum value?
a) { $minimum: <int> }
b) { $min: <expression>}
c) { $minimum: <expression> }
d) None of the mentioned
View Answer

Answer: b
Explanation: $min returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.
advertisement

8. If all documents for the $min operation have null value for the field or are missing the field, the $min operator returns ____ for the minimum value.
a) 1
b) 0
c) null
d) none of the mentioned
View Answer

Answer: c
Explanation: If some, but not all, documents for the $min operation have either a null value for the field or are missing the field, the $min operator only considers the non-null and the non-missing values for the field.

9. $addToSet returns an array of all _______ values that results from applying an expression to each document.
a) unique
b) non unique
c) distinct
d) all of the mentioned
View Answer

Answer: a
Explanation: Order of the elements in the output array is unspecified.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

To practice all areas of MongoDB for entrance exams, Here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter