Using MS SQL how to use select criteria based on sum : Given the below table and using SQL (sql-server preferred), how can I do a select so that only the ProductID's that sum to the first 200 orders or less is returned. In other works, I'd like ID's for 'Corn Flakes', 'Wheeties' returned since this is close to the sum of 200 orders but returning anything more would be over the limit.



[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/x88aZ.png