Site icon Hip-Hop Website Design and Development

Need a SQL Query to return Products, their total sales, their total sales rank, and its category if it matches a one of 5 specific strings [closed]

I am trying to create a SQL query that returns:

  1. Product Title (for all products)
  2. The Total SUM of sales (dollar value, not transaction count) for each product expressed as currency
  3. The Rank for each Product, based on the total sum of sales
  4. 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.