Skip to content

Instantly share code, notes, and snippets.

@RedaAffane
Last active March 6, 2018 09:36
Show Gist options
  • Save RedaAffane/7577dd2b67de9d4bb544702cedcadeb0 to your computer and use it in GitHub Desktop.
Save RedaAffane/7577dd2b67de9d4bb544702cedcadeb0 to your computer and use it in GitHub Desktop.
Compute the worth of each coalition
SELECT "channels_subset",
sum("conversion") as "conversions_sum"
FROM
(
SELECT "user_id",
string_agg(DISTINCT("channel"), ',') as "channels_subset",
max("conversion") as "conversion"
FROM
(
SELECT "user_id",
"channel",
"conversion"
FROM "MARKETINGATTRIBUTIONSIMULATIONS_simulated_data"
ORDER BY
"user_id",
"channel"
)a
group by "user_id"
)b
GROUP BY "channels_subset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment