title: Mongodb Aggregation pipeline: Is it possible to do $match based on two conditions?
body: <p>I am new to Mongodb, been working on an aggregation pipeline. Have this collection called students:-</p>
  <pre><code>{ &quot;_id&quot; : ObjectId(&quot;62304f3a53b273b7a6ea0eca&quot;), &quot;name&quot; : &quot;Ankita&quot;, &quot;subject&quot; : &quot;English&quot;, &quot;marks&quot; : 70 }
  { &quot;_id&quot; : ObjectId(&quot;62304f3a53b273b7a6ea0ecb&quot;), &quot;name&quot; : &quot;Ritwik&quot;, &quot;subject&quot; : &quot;Maths&quot;, &quot;marks&quot; : 80 }
  { &quot;_id&quot; : ObjectId(&quot;6232c4b8c2f3cc1a0e9fa107&quot;), &quot;name&quot; : &quot;Mayank&quot;, &quot;subject&quot; : &quot;Science&quot;, &quot;marks&quot; : 85 }
  { &quot;_id&quot; : ObjectId(&quot;6232c4b8c2f3cc1a0e9fa108&quot;), &quot;name&quot; : &quot;Ankita&quot;, &quot;subject&quot; : &quot;History&quot;, &quot;marks&quot; : 90 }
  { &quot;_id&quot; : ObjectId(&quot;6232c4b8c2f3cc1a0e9fa109&quot;), &quot;name&quot; : &quot;Ritwik&quot;, &quot;subject&quot; : &quot;Economics&quot;,  &quot;marks&quot; : 75 }
  { &quot;_id&quot; : ObjectId(&quot;6232fa5fc2f3cc1a0e9fa10a&quot;), &quot;name&quot; : &quot;Mayank&quot;, &quot;subject&quot; : &quot;Polity&quot;, &quot;marks&quot; : 60 }
  </code></pre>
  <p>Based on a given number, asOfMarks(lets say 65 here) and given includeNames( lets say ['Mayank','Ankita'] here), I want the result to be something like this:-</p>
  <pre><code>{ &quot;name&quot; : &quot;Mayank&quot;, &quot;marks&quot; : 60, &quot;subject&quot; : &quot;Polity&quot; }
  { &quot;name&quot; : &quot;Ankita&quot;, &quot;marks&quot; : 70, &quot;subject&quot; : &quot;English&quot; }
  </code></pre>
  <p>It should group by the includeNames provided, and If there exists a row with marks less than the asOfMarks, show rows with marks just less than the asOfMarks, ( like that in case of 'Mayank'). If not, show the row with the minimum marks(like in case of 'Ankita')</p>