tsql - SQL Server SUM GROUP BY Help -
i have table contains orderid
, inventoryid
, , quantity
-- line items table. database sql server 2008.
what need know how write sql statement returns sums of quantities itemid
@ order, not counting orders have larger orderids
it. must return orderid
, itemid
, , total
.
any help? thanks!
guess:
select sum(quantity) total, --"sums of quantities itemid @ order" orderid, inventoryid --"it must return orderid, itemid" orderid < (some larger order id value) --"not counting orders have larger orderids" group orderid, inventoryid
Comments
Post a Comment