0

How many products have discount % greater than 30%? On pymongo (MongoDB driver library for Python), I have

  • original_price [store as float] and
  • sale_price [store as float]

in mongoDB, I am using:

# question 10:-How many products have discount % greater than 30%?
count=0
for x in db.leclerc_fr.find():
    if((x['sale_price']/x['original_price']<.7)):
        print(x)
        count+=1
print(count)
  • 1
    Does this answer your question? [Mongo field A greater than field B](https://stackoverflow.com/questions/16042315/mongo-field-a-greater-than-field-b) combined with `.length()` maybe – JonSG Jan 11 '23 at 18:34
  • Do you have to use `where`, or could you use an aggregation pipeline? – rickhg12hs Jan 12 '23 at 01:26

0 Answers0