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.uordidThis 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?