Retrieve data based on sum of rows group by product - SQL, SSMS

My data comprises of "Stock Qty" and would like to know what the qty recieved was and the purchased price was based on the latest purchase orders - only up to the qty currently available.
I am able to do this to and created a new calculated column called "Stock Qty New".

So in my attached example, I would now like to filter to show on the rows where the sum of "Stock Qty New" is <= to "Stock Qty" by ProductId.
("Stock Qty" is correctly repeating and shown validating purposes).

So for ProductId AA08510, I would want to see row number 1 only as the first Purchase Order has the 13 items which make the current stock.
For ProductId DZ51855, I would want to see row numbers 4,5 only as both Purchase Orders have 145 items (100 + 45) which make the current stock.
For ProductId FC03201, I would want to see row numbers 6,7 only as both Purchase Orders have 4 items (3 + 1) which make the current stock.



Any suggestions much appreciated and let me know if further information required.
Thanks in advance.
Stock.docx
Bhagat SBusiness Intelligence AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
I think you just need this. Please try

Select * from yourTable
WHERE  [Stock Qty New]  > 0
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bhagat SBusiness Intelligence AnalystAuthor Commented:
Yes, this works fine.
Many thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.