3

I got following query

SELECT  
            CONCAT(address.firstname,' ',
            address.lastname) AS Name,
            address.email AS Email,
            items.created_at AS Date,
            items.name AS Description,
            items.store_id AS Logon,
            items.name AS Category,
            items.store_id AS FeedbackDate,              
            items.sku AS ProductSearchcode,
            items.order_id AS Orderref  

   FROM sales_flat_order AS orders
      JOIN sales_flat_order_item AS items 
      ON items.order_id = orders.entity_id 
      LEFT JOIN sales_flat_order_address AS address
      ON orders.entity_id = address.parent_id

  WHERE    
  items .created_at BETWEEN  '2014-04-15 00:00:00' AND '2014-07-30 00:00:00'

This work fine for me, but I want to output only completed orders not created(items .created_at).

How to achieve this ?

Thx

3

Try to add AND orders.status = 'complete'

Here is the full query:

SELECT  
            CONCAT(address.firstname,' ',
            address.lastname) AS Name,
            address.email AS Email,
            items.created_at AS Date,
            items.name AS Description,
            items.store_id AS Logon,
            items.name AS Category,
            items.store_id AS FeedbackDate,              
            items.sku AS ProductSearchcode,
            items.order_id AS Orderref  

   FROM sales_flat_order AS orders
      JOIN sales_flat_order_item AS items 
      ON items.order_id = orders.entity_id 
      LEFT JOIN sales_flat_order_address AS address
      ON orders.entity_id = address.parent_id

  WHERE    
  items .created_at BETWEEN  '2014-04-15 00:00:00' AND '2014-07-30 00:00:00'
  AND orders.status = 'complete'

Also you can add AND orders.status in ('processing', 'complete') depending upon your requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.