Skip to content

Instantly share code, notes, and snippets.

@gmacdougall
Created December 6, 2016 18:41
Show Gist options
  • Select an option

  • Save gmacdougall/fe10cebd002f007ff3b33a72444909e4 to your computer and use it in GitHub Desktop.

Select an option

Save gmacdougall/fe10cebd002f007ff3b33a72444909e4 to your computer and use it in GitHub Desktop.
SELECT
spree_orders.id
FROM
spree_orders
WHERE (
spree_orders.id IN (
SELECT order_id
FROM spree_orders_promotions
INNER JOIN
spree_promotion_codes
ON spree_promotion_codes.id = spree_orders_promotions.promotion_code_id
WHERE spree_promotion_codes.value LIKE '%first15%'
)
AND spree_orders.completed_at IS NOT NULL
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment