Hello,
I want to create an SQL query where I pull the name of each manufacturer and their total sales done in a specified date range.
Manufacturer Name | Total Sales
I have a query where I pull the manufacturer names:
SELECT DISTINCT B.value AS "MANUFACTURER" FROM `eav_attribute_option` AS A
LEFT JOIN `eav_attribute_option_value` AS B ON A.option_id = B.option_id
WHERE A.attribute_id = 81
And I have a query where I get the total sales of each product:
SELECT B.value AS "BARCODE", A.sku AS "SKU", A.name AS "NAME", A.price AS "PRICE",
COUNT(A.sku) AS "QUANTINTY", SUM(A.price) AS "TOTAL" , A.created_at AS "DATE"
FROM `sales_order_item` AS A
left JOIN `catalog_product_entity_varchar` AS B on A.`product_id` = B.`entity_id`
WHERE (A.created_at LIKE "2015-11%" OR A.created_at LIKE "2015-12%")
AND B.attribute_id = 148 GROUP BY A.sku ORDER BY `DATE` ASC
I am struggling in connecting those two, as I need the basic functionality of each. I cannot find a key that connects the tables I need.
Thanks in advance and have a great rest of the day!