0

Write query to find the restaurant Id, name, and grades for those restaurants which achieved a grade of "A" and scored 11 on an ISODate "2014-08-11T00:00:00Z" among many of survey dates..

*My answer is as :

db.resCollec.find( { "grades.date": ISODate("2014-08-11T00:00:00Z"), 
"grades.grade":"A" , 
"grades.score" : 11 },
 {"restaurant_id" : 1,"name":1,"grades":1} );

This solution is not correct.What should i change in it

The solution is not correct though

yori
  • 9
  • 3
  • Are you sure you want to compare "grades.date" to an exact date and time? If it could be anytime on 11/08/2014, then you could use "$gte" and "$lt" to check an interval instead: `"grades.date": {$gte: ISODate("2014-08-11T00:00:00Z"), $lt: ISODate("2014-08-12T00:00:00Z")}` – Alberto Trindade Tavares Jul 28 '20 at 12:59
  • @AlbertoTrindadeTavares ....but still the solutions from other dates are displayed along with grades and scores out of the one specified too. – yori Jul 28 '20 at 13:09

0 Answers0