0% found this document useful (1 vote)
1K views2 pages

MongoDB Exercise

The document describes creating a sales collection with multiple documents containing fields like store, product, quantity, region, items, amount, price, sales, and customer age. It lists 17 queries to run on the collection including finding documents by city, sales amount, agent score, store rating and merchandise status, and performing operations like skips, limits, sorting, and mathematical comparisons.

Uploaded by

Abhay Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
1K views2 pages

MongoDB Exercise

The document describes creating a sales collection with multiple documents containing fields like store, product, quantity, region, items, amount, price, sales, and customer age. It lists 17 queries to run on the collection including finding documents by city, sales amount, agent score, store rating and merchandise status, and performing operations like skips, limits, sorting, and mathematical comparisons.

Uploaded by

Abhay Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Create a collection called sales. Create multiple documents with keys like store (id, name etc.

),
product (type, name etc.), quantity, region, items, amount, price, sales, customer age etc. with
arrays and other data types wherever applicable. Please go through the queries first and you
would know how many documents to create with what key value pairs.

1. Write a MongoDB query to display all the documents in the collection.

2. Write a MongoDB query to display the fields; products and price for all the documents in the
collection.

3. Write a MongoDB query to display all the fields but exclude the field _id for all the
documents in the collection.

4. Write a MongoDB query to display the fields product and quantity, but exclude the field _id
for all the documents in the collection.

5. Write a MongoDB query to display all the sales that happened in Delhi.

6. Write a MongoDB query to display the first 5 sales happened in Delhi.

7.Write a MongoDB query to display the next 5 sales after skipping first 5 which happened in
Delhi

8. Write a MongoDB query to find the sales agents who achieved a score more than 90.

9. Write a MongoDB query to find the sales agents that achieved a score, more than 80 but less
than 100.

10. Write a MongoDB query to find the outlets which are located in Jaipur.

11. Write a MongoDB query to find the stores that do not sell merchandise and the user rating is
more than 70.

12. Do the same query without using $and operator.


13. Write a MongoDB query to find the stores which do not sell any merchandise and achieved a
user rating of 90+ and do not belong to Delhi. The documents must be displayed according to the
products in descending order.

14. Write a MongoDB query to find the store Id, name, and total sales for those stores which
contain A' as first letter for the name of city.

15. Write a MongoDB query to find the store Id, name, and total sales for those stores which
contain I as the last letter for the name of city.

16. Write a MongoDB query to know whether all the addresses contain the pin code or not.

17. Write a MongoDB query which will select the Store Id, name and customer rating score for
those stores which returns 0 as a remainder after dividing the score by 5.

You might also like