I am trying to create a SQL query that returns:
- Product Title (for all products)
- The Total SUM of sales (dollar value, not transaction count) for each product expressed as currency
- The Rank for each Product, based on the total sum of sales
- The Product Category if it matches one of 5 possible categories (every product is assigned 4 categories, 1 of the 4 categories will always be one of the 5 possible categories I’d like to return here)
I’ve been able to achieve several of these items in isolated queries, but I cannot get them all to work together in a single query. In addition, I’m struggling to make #4 above function and how to successfully map the category back to the product.
Any help or suggestions would be greatly appreciated!
EDIT: I’m using WooCommerce as my primary eCommerce Plugin.