Works for me.drop table #TMPSelect *into #TMPfrom(select convert(decimal(10,5),0) as x, convert(decimal(10,5),913.07) as y , 041604 as mygroup Union allselect 0, 37162.86, 041604 Union allselect 0, 4275.4 , 041604 Union allselect 0, 22464.44, 041604 Union allselect 44285, 0, 041604 Union allselect 20530.77, 0, 041604) aselect mygroup,sum(x) -sum(y)from #TMPgroup by mygroupselect mygroup, sum(x - y)from #TMPgroup by mygroup
Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881