You can use your previous select as derived table. See changes below
>I am using a sum and group by in my query to find differences in a total field in a parent table and the child tables.
>
SELECT SUM(td.diff)
FROM (
>select o.ytotalorder-sum(ar.yamttrans) as diff
>from orders o inner join orderardetail ar on o.uordid=ar.uordid
>where (ar.cartypid='II' or ar.cartypid='IM')
> and o.tcreate>='2002-12-18' group by o.uordid,o.ytotalorder
>having o.ytotalorder>sum(ar.yamttrans)
>order by o.uordid
) td
>
>This works fine. It gives me a list of the orders that are out of balance. Now I want to get a grand total of those differences (sum the difference). Is there a way to do it in T-Sql?
--sb--