Count rows with higher bid than current offer Linq to SQL
<p>In the following table, idea is to count each bid with higher bids having the status 1,</p>
<pre><code>id  rate    cur Request Sold    request at  status
1   13  USD 400 0   2016-12-08 11:28:01 1
2   13  USD 400 0   2016-12-08 11:29:01 1
3   12  USD 400 0   2016-12-08 11:29:01 1
4   12  USD 400 0   2016-12-08 11:31:01 1
5   10  USD 400 0   2016-12-08 11:31:01 1
                        
        new     1           
        sold    2           
</code></pre>
<p>this is the query I run for:</p>
<pre><code>  int selectedBid = 5;
  decimal selectedBidOfer = 10;
  int higherbid = db.bids.Where(a=&gt;a.StatusId == 1 &amp;&amp;
                                   a.bidId != selectedBid &amp;&amp;
                                   a.bidOffer&gt;= selectedBidOfer ).Count();

  return Content(higherbid.ToString());
</code></pre>
<p>this will be the result in each change:</p>
<p>if</p>
<blockquote>
<p>int selectedBid = 5; decimal selectedBidOfer = 10;  result will be 4,
which is correct</p>
<p>int selectedBid = 4; decimal selectedBidOfer = 12;  result will be 3,
which is correct</p>
<p>int selectedBid = 3; decimal selectedBidOfer = 12;  result will be 3,
which is not correct, it should result 2 only upper value</p>
</blockquote>
<p>Note: here the bidId may not be in order so I could check based on that and time is also not in order means one can give high rate at end and ....</p>
<p>so how will I be able find out the higher bid with status 1, in the explained case?</p>