SELECT
orders.increment_id AS orderId,
CONCAT(address.firstname,' ',
address.lastname) AS name,
address.email AS email,
address.telephone AS telephone,
items.created_at AS createdAt
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 items.store_id = 1
GROUP BY orderId
SELECT
orders.increment_id AS orderId,
CONCAT(address.firstname,' ',
address.lastname) AS name,
address.email AS email,
address.telephone AS telephone,
items.created_at AS createdAt
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.store_id = 1 and city LIKE '%Москва%'
GROUP BY email
### Вытащить информацию по товарам из постельрф только по КПБ
```
SELECT sfo.entity_id, sfo.customer_id, sfoi.order_id, sfoi.sku, sfoi.name, sfoi.qty_ordered, sfoi.row_total_incl_tax
FROM `sales_flat_order` AS sfo
INNER JOIN `sales_flat_order_item` AS sfoi
ON sfo.entity_id = sfoi.order_id
INNER JOIN `catalog_product_entity` AS cpe
ON cpe.entity_id = sfoi.product_id
WHERE cpe.attribute_set_id = 9 AND sfo.store_id = 2
```