I have a following problem as in the example. I have to join two tables based on the aggregated columns. These are the only way to combine these two tables. Is it possible to do this? I have tried Having by - procedures, without any success.
Select a.customerID, sum(a.Items) as Amount a sum(b.Items) as Amount b From Orders a Join Table B on SUM(a.Items) = SUM(b.Items) Group By a.CustomerID