Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trabulium/db3da9161c83d055ad26609bc4f8a3cd to your computer and use it in GitHub Desktop.
Save trabulium/db3da9161c83d055ad26609bc4f8a3cd to your computer and use it in GitHub Desktop.
select sfo.customer_id, cg.customer_group_code, customer_firstname, customer_lastname, customer_email, street, city, region, postcode, country_id, sfoi.type, sfoi.sku, sfoi.name, sfoi.qty_ordered
FROM sales_flat_order as sfo
LEFT JOIN sales_flat_order_address sfoa on (sfo.entity_id = sfoa.parent_id)
LEFT JOIN (SELECT order_id, GROUP_CONCAT(product_type, '\n') as type, GROUP_CONCAT(sku, "\n") as sku, GROUP_CONCAT(name, "\n") as name, GROUP_CONCAT(qty_ordered, "\n") as qty_ordered from sales_flat_order_item GROUP BY order_id) as sfoi on sfo.entity_id = sfoi.order_id
LEFT JOIN customer_group as cg on (sfo.customer_group_id = cg.`customer_group_id`)
WHERE `sfoa`.`address_type` = "shipping"
ORDER BY customer_id ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment