Last active
September 28, 2018 16:44
-
-
Save jtbg/e9281b4365a521b7cc8788ec68ec4558 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, | |
name, | |
num_prod, | |
vendor_product_count | |
FROM | |
(SELECT vendor_id, | |
count(*) AS num_prod | |
FROM products | |
GROUP BY vendor_id) foo | |
RIGHT JOIN | |
(SELECT id, | |
name, | |
vendor_product_count | |
FROM vendors) bar ON foo.vendor_id = bar.id | |
WHERE COALESCE(num_prod, 0) != vendor_product_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment