I have a table that contains an orderid, an inventoryid, and a quantity — its a line items table. The database is SQL Server 2008.
What I need to know is how to write a SQL statement that returns the sums of quantities for that itemid at that order, not counting orders that have larger orderids than it. It must return the orderid, itemid, and total.
Any help? Thanks!
Guess: