Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emschwar/165926 to your computer and use it in GitHub Desktop.
Save emschwar/165926 to your computer and use it in GitHub Desktop.
SELECT manifests.campaign_id,SUM(delivery_item_entries.impressions)
FROM delivery_item_entries
INNER JOIN delivery_items on delivery_item_entries.delivery_item_id = delivery_items.id
INNER JOIN third_party_placements on delivery_items.third_party_placement_id = third_party_placements.id
INNER JOIN ordered_placements on third_party_placements.ordered_placement_id = ordered_placements.id
INNER JOIN placements on ordered_placements.id = placements.ordered_placement_id
INNER JOIN plan_rows on placements.plan_row_id = plan_rows.id
INNER JOIN plans on plan_rows.plan_id = plans.id
INNER JOIN manifests on plans.manifest_id = manifests.id
WHERE delivery_item_entries.closing_id = 1
GROUP BY manifests.campaign_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment