title: How do you add a condition like Count or Countif to limit in Query function?
body: <pre><code>=query(B8:BQ293,"Select D Order by E Desc limit 5",-1)
  </code></pre>
  
  <p>The following works, but I want to add something to limit, so that 5 isn't a static variable, but based on some condition on another column.</p>
  
  <p>What I want is to return a sorted column "D" based on column E like described, but D variables are longer than column E, and I just want to limit it to the length of column E.</p>