0

As the title says, I am running a few queries on a Magento 2 DB, but they never execute. When I run the queries on the server, the DB disk gets full and the queries don't stop loading, but when I run them locally they never execute.

The first query is:

SELECT B.value AS "BARCODE", A.sku AS "SKU", A.name AS "NAME", A.price AS "PRICE", A.created_at AS "DATE" FROM `sales_order_item` AS A INNER JOIN `catalog_product_entity_varchar` AS B 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

Which basically displays a sales report.

The second one is:

SELECT A.value AS "MANUFACTURER", SUM(B.price) AS "TOTAL" FROM `sales_order_item' AS B INNER JOIN `catalog_product_entity_varchar` AS A WHERE A.attribute_id = 81 AND B.created_at LIKE "%%" OR B.created_at LIKE "%%"
GROUP BY A.value

Which does the same just at a manufacturer level instead of product level.

Am I doing something completely wrong or am I just missing something?

Thank in advance and have a great day.

2
  • what result you want to get ? Commented Jul 11, 2022 at 10:26
  • Are you sure it not returning no result? Does your DB has order from 2015? Also, I don't think your sql is correct try SELECT B.value AS "BARCODE", A.sku AS "SKU", A.name AS "NAME", A.price AS "PRICE", 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 "2021-11%" OR A.created_at LIKE "2021-12%") AND B.attribute_id = 88 GROUP BY A.sku ORDER BY `DATE` ASC Commented Jul 11, 2022 at 18:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.