I have two tables as follows
PRODUCT table
PRODUCT
Id | Name | Price
And an ORDERITEM table
ORDERITEM
Id | Orde
select orderID, sum(subtotal) as order_total from ( select orderID, productID, price, qty, price * qty as subtotal from product p inner join orderitem o on p.id = o.productID where o.orderID = @orderID ) t group by orderID