Performing Calculations WIth Join
You could get aggregates before to join both tables.




;WITH g1 AS
(
    SELECT sn, SUM(samt) AS samt
    FROM   @Sub
    WHERE  ssd &gt;= '20170601' AND ssd &lt;= '20170605'
    GROUP BY sn
)
, g2 AS
(
    SELECT sn, SUM(amt) as amt
    FROM   @Main
    WHERE  sd &gt;= '20170601' AND sd &lt;= '20170605'
    GROUP BY sn
)
SELECT g1.sn AS SalesPerson,
       g1.samt AS SalesAmt,
       (g1.samt - g2.amt) AS DiffAmp
FROM   g1
JOIN   g2
ON     g1.sn = g2.sn;
GO



SalesPerson | SalesAmt | DiffAmp
:---------- | -------: | ------:
G           |       11 |     -33



dbfiddle here