I need to write a query to retrive the list of products that do not have a sales history. Can someone help. Thank you
Please find below the query to retrieve the list of products that do not have any sales history:
SELECT sku FROM catalog_product_entity WHERE sku NOT IN (SELECT sku FROM sales_order_item)
Please let us know if you require any further assistance.
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
WHERE product_id NOT IN (
SELECT DISTINCT product_id
This query selects all rows from the products table where the product_id is not present in the subquery that selects all distinct product_id values from the sales table. By using a subquery, we can check for products that have no sales history and exclude them from the result set.
regards: London Tours
This query uses a subquery to first retrieve a list of distinct product IDs from the "sales" table. It then uses the NOT IN operator to retrieve all products from the "products" table whose IDs are not in this list, indicating that they do not have a sales history.