I am trying this on a test table (id bigint, operationsid bigint) but i get a +10 difference!!--- edo an valeis 12343123 einai gia na paei kato kato to total sumSELECT id, sum(Sales) SalesFROM (SELECT COALESCE(T2.id, 12343123) id, T1.Sales FROM (SELECT id, sum(operationsid) Sales FROM drugsoperations GROUP BY id ) T1 left JOIN (SELECT TOP 10 id, sum(operationsid) Sales FROM drugsoperations GROUP BY id) T2 on T1.id = T2.id ) TGROUP BY T.id
So i get 2899 on the last line but if i do it by calculator i get 2889!does it have to do by somehow adding 1 one, due to the top 10?!