Created
June 19, 2015 07:45
-
-
Save woogist/04d67cadb967955c0a43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM( meta__order_total.meta_value) as total_sales,SUM( meta__order_shipping.meta_value) as total_shipping,SUM( meta__order_tax.meta_value) as total_tax,SUM( meta__order_shipping_tax.meta_value) as total_shipping_tax, posts.post_date as post_date FROM wp_posts AS posts LEFT JOIN wp_postmeta AS meta__order_total ON posts.ID = meta__order_total.post_id LEFT JOIN wp_postmeta AS meta__order_shipping ON posts.ID = meta__order_shipping.post_id LEFT JOIN wp_postmeta AS meta__order_tax ON posts.ID = meta__order_tax.post_id LEFT JOIN wp_postmeta AS meta__order_shipping_tax ON posts.ID = meta__order_shipping_tax.post_id LEFT JOIN wp_posts AS parent ON posts.post_parent = parent.ID | |
WHERE posts.post_type IN ( 'shop_order_refund','shop_order' ) | |
AND posts.post_status IN ( 'wc-completed','wc-processing','wc-on-hold') | |
AND ( parent.post_status IN ( 'wc-completed','wc-processing','wc-on-hold') OR parent.ID IS NULL ) | |
AND posts.post_date >= '2015-06-13' | |
AND posts.post_date < '2015-06-20' | |
AND meta__order_total.meta_key = '_order_total' AND meta__order_shipping.meta_key = '_order_shipping' AND meta__order_tax.meta_key = '_order_tax' AND meta__order_shipping_tax.meta_key = '_order_shipping_tax' GROUP BY YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date) ORDER BY post_date ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment