Skip to content

Instantly share code, notes, and snippets.

@beck03076
Last active December 23, 2015 11:29
Show Gist options
  • Save beck03076/edf1a8bb3da516c0e9cd to your computer and use it in GitHub Desktop.
Save beck03076/edf1a8bb3da516c0e9cd to your computer and use it in GitHub Desktop.
SELECT DISTINCT COUNT(DISTINCT `products`.`id`)
FROM `products`
WHERE (moderation_status in ('QUEUED','QUEUED_AFTER_APPROVAL','QUEUED_AFTER_REJECT','PROMOTED')
OR treasureProduct.products.id in (NULL))
/*=====================*/
SELECT COUNT(DISTINCT u.id) AS Listers,COUNT(p.id)AS Listings
FROM accounts.users u
LEFT JOIN
treasureProduct.products p
ON
u.id=p.user_id
WHERE
u.status='verified'
AND
p.status='active'
AND
p.created_at < TIMESTAMP(SYSDATE());
/*=====================*/
SELECT p.source as source, COUNT(p.id)AS Listings
FROM accounts.users u
LEFT JOIN treasureProduct.products p
ON u.id=p.user_id
WHERE u.status='verified'
AND p.status='active'
AND p.created_at BETWEEN TIMESTAMP(CURDATE())
AND TIMESTAMP(SYSDATE())
GROUP BY 1\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment