Skip to content

Instantly share code, notes, and snippets.

@emschwar
Created August 12, 2009 20:04
Show Gist options
  • Save emschwar/166720 to your computer and use it in GitHub Desktop.
Save emschwar/166720 to your computer and use it in GitHub Desktop.
SELECT agencies.name
FROM agencies
INNER JOIN manifests ON manifests.agency_id = agencies.id
INNER JOIN plans ON plans.manifest_id = manifests.id
INNER JOIN plan_rows ON plan_rows.plan_id = plans.id
INNER JOIN placements ON placements.plan_row_id = plan_rows.id
INNER JOIN ordered_placements ON placements.ordered_placement_id = ordered_placements.id
WHERE ordered_placement_id = 87952
AND plans.id = MAX(plans.id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment