When calculating total revenues or ROI per campaign we joined some tables first and then applied grouping and counting or grouping and summing to the joined table.
Sometimes we aren’t that lucky and we have results of aggregations in different tables. How to join them if there’s no foreign key or mutual column (like we had with utm_campaign)?
Percentage of customers
Imagine we’d have two different tables – one would contain number of users, the other one number of customers. We can emulate this scenario using CTEs:
WITH users_count AS ( SELECT...