title: How to write a subquery in where condition in Azure cosmos db to get a id which has different source id's in multiple documents but in same collection
body: <p>I've one collection which has multiple documents as below. How write select query to orderid's which has two source's  &quot;OrderStatus&quot;, &quot;PlacedOrder&quot;  in Azure Cosmos?</p>
  <p>I am trying below queries but they are not working</p>
  <ol>
  <li>select c.orderid from c where  c.source='OrderStatus' and c.source='PlacedOrder'</li>
  <li>select c.orderid from c where c.source='OrderStatus' and c.orderid in (select c.orderid from c where c.source='PlacedOrder')</li>
  </ol>
  <p>Please help me writing this query in right way. Thanks!.</p>
  <p>[
  {
  &quot;source&quot;: &quot;PlacedOrder&quot;,
  &quot;orderid&quot;: &quot;10490102&quot;,
  &quot;storeid&quot;: &quot;50&quot;,
  &quot;data&quot;: {}
  }
  ]</p>
  <p>[
  {
  &quot;source&quot;: &quot;OrderStatus&quot;,
  &quot;orderid&quot;: &quot;10490103&quot;,
  &quot;storeid&quot;: &quot;50&quot;,
  &quot;data&quot;: {}
  }
  ]</p>
  <p>[
  {
  &quot;source&quot;: &quot;OrderStatus&quot;,
  &quot;orderid&quot;: &quot;10490102&quot;,
  &quot;storeid&quot;: &quot;50&quot;,
  &quot;data&quot;: {}
  }
  ]</p>