Skip to content

Instantly share code, notes, and snippets.

@gmacdougall
Last active August 29, 2015 14:00
Show Gist options
  • Save gmacdougall/ed03a0340ae79b3470ab to your computer and use it in GitHub Desktop.
Save gmacdougall/ed03a0340ae79b3470ab to your computer and use it in GitHub Desktop.
SELECT COUNT(*)
FROM "spree_products"
LEFT OUTER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."deleted_at" IS NULL
WHERE "spree_products"."deleted_at" IS NULL
AND spree_variants.id NOT IN (SELECT variant_id FROM spree_well_amy_variant_lifestyles WHERE "lifestyle_id" IN (1, 2, 3, 4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment