hp coupon salesrule export report
SELECT o.increment_id as 'Order ID', oi.base_price as 'Unit Value', oi.name as 'Product', oi.qty_ordered as 'Quantity'
FROM rewards_transfer t
left JOIN sales_flat_order o
ON t.reference_id = o.entity_id
left JOIN sales_flat_order_item oi
ON oi.order_id = o.entity_id
left JOIN catalog_product_entity_int p
ON oi.product_id = p.entity_id
WHERE t.reason_id = 1
AND t.status_id = 5 AND t.quantity > 0
AND o.created_at >= '2017-11-19 11:00:00'
AND o.created_at <= '2017-12-21 11:00:00'
AND p.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = "brand")
AND p.value IN (SELECT entity_id from brand_entity_varchar where value = 'Thompson\'s')
AND oi.row_total > 0
;