SELECT *, SUM(TCV) AS sales, current_sales - SUM(TCV) AS difference FROM `sales` LEFT JOIN (SELECT customerKey AS customerID, SUM(TCV) AS c