Last active
July 3, 2017 15:58
-
-
Save GreatPotato/4494595 to your computer and use it in GitHub Desktop.
Gets the 50 top selling products that cost over 15.00
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 t3.name, t3.sku, t3.price, count(t1.shop_product_id) AS "Number of orders" | |
FROM shop_order_items t1 | |
LEFT JOIN shop_orders t2 | |
ON t1.shop_order_id = t2.id | |
LEFT JOIN shop_products t3 | |
ON t1.shop_product_id = t3.id | |
WHERE t2.payment_processed != '' | |
AND t3.price > 15.00 | |
GROUP BY t1.shop_product_id | |
ORDER BY count(t1.shop_product_id) DESC | |
LIMIT 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment