Skip to content

Instantly share code, notes, and snippets.

@polevaultweb
Created June 25, 2020 15:13
Show Gist options
  • Save polevaultweb/e0487d5b1a33e8005009e4890103f0aa to your computer and use it in GitHub Desktop.
Save polevaultweb/e0487d5b1a33e8005009e4890103f0aa to your computer and use it in GitHub Desktop.
Get your best sales day total for an Easy Digital Downloads WordPress store
SELECT Date(post_date) as Date,
Round(Sum(pm.meta_value - pm1.meta_value)) as Total
FROM wp_posts p
INNER JOIN wp_postmeta pm
ON p.id = pm.post_id
AND pm.meta_key = '_edd_payment_total'
INNER JOIN wp_postmeta pm1
ON p.id = pm1.post_id
AND pm1.meta_key = '_edd_payment_tax'
WHERE post_type = 'edd_payment'
AND post_status = 'publish'
GROUP BY Date(post_date)
ORDER BY 2 DESC
LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment