select OD.Id, count(IM.Item_Id), sum(IM.ItemCost * OD.ItemQuantity) from OrderMaster OM join OrderDetail ...
stackoverflow.com