Skip to content

Instantly share code, notes, and snippets.

@kalenjordan
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kalenjordan/9234803 to your computer and use it in GitHub Desktop.
Save kalenjordan/9234803 to your computer and use it in GitHub Desktop.
/* Here are some example custom report queries for use with the custom
* reports module
*
* http://magemail.co/free-custom-reports-module-for-magento/
*/
/*
* Number of items in order
*
* Useful to find out whether customers are buying a given product
* standalone or with other products.
*/
SELECT i.qty_ordered AS `Items in Order`,
COUNT(*) AS `Number of Orders`,
SUM(base_grand_total) AS `Total Revenue`
FROM sales_flat_order AS o
LEFT JOIN sales_flat_order_item AS i ON i.order_id = o.entity_id
WHERE i.`sku` IN ('SKU')
GROUP BY i.qty_ordered
LIMIT 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment