title: Select the matching/sum up total in SQL Server
body: <p>I want to get all the id's that matches/sum up my total qty.</p>
  
  <p>Example if my total qty is 40 then my query will stops until it sums up all the qty at exactly or greater than 40.</p>
  
  <p>See screenshots</p>
  
  <p><a href="https://i.stack.imgur.com/Xg9KI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xg9KI.png" alt="enter image description here"></a></p>