Assignment 4
Instruction:
Include a full screenshot that shows the code and the output for each question.
You are given a MongoDB collection named employees with documents having the following structure:
"_id": ObjectId("60c940888b64832e448a7b0f"), "name": "John Doe", "age": 35, "department": "IT", "salary": 60000}
{"_id": ObjectId("60c940888b64832e448a7b10"), "name": "Bob Johnson", "department": "Sales", "salary": 62000, "manager": "Alice Smith"}
{"_id": ObjectId("60c940888b64832e448a7b11"), "name": "Emily Brown", "department": "HR", "salary": 58000, "manager": "Alice Smith"}
Write MongoDB queries to perform the following operations:
a) Retrieve all documents where the age is greater than 30 and the department is 'Sales'.
b) Retrieve all documents where the salary is greater than 50000 or the age is less than 25.
c) Retrieve all documents where the department is either 'HR' or 'Finance' and the age is less than or equal to 40.
d) Retrieve all documents where the salary is greater than or equal to 70000 and the department is not 'IT'.
e) Retrieve all documents where the name is not equal to 'John Doe' and the department is not equal to 'HR'.