fixed the costs sub table query