Skip to content

Instantly share code, notes, and snippets.

@kmarenov
Created September 20, 2017 14:24
Show Gist options
  • Select an option

  • Save kmarenov/6754c013c28266b291b9e09226ba9cda to your computer and use it in GitHub Desktop.

Select an option

Save kmarenov/6754c013c28266b291b9e09226ba9cda to your computer and use it in GitHub Desktop.
SELECT COUNT(t.product_id)
FROM
(SELECT ppc.product_id AS product_id
FROM product__product_category ppc
LEFT JOIN classification__category cc ON ppc.category_id = cc.id
WHERE cc.context = 'brands'
GROUP BY ppc.product_id
HAVING COUNT(ppc.category_id) > 1
) AS t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment