Created
September 18, 2019 01:01
-
-
Save barryhughes/300d6b06acdbdbcde43ff6988b7202b1 to your computer and use it in GitHub Desktop.
Build a list of user IDs, ordered by the number of known (WooCommerce) subscriptions each user is associated with.
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 meta_value AS user_id, | |
COUNT(*) AS subscription_count | |
FROM wp_posts | |
JOIN wp_postmeta ON ID = post_id | |
WHERE post_type = 'shop_subscription' | |
AND meta_key = '_customer_user' | |
GROUP BY meta_value | |
ORDER BY subscription_count DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment