select ob.Quantity,ob.UnitPrice ,r.TotalPrice from dbo.OrderBook ob inner join (select OrderId , sum(TotalPrice ) TotalPrice from dbo.Orders group by OrderId ) r on ob.OrderID =r.OrderId