Monthly revenue in WooCommerce
WooCommerce revenue grouped by month from completed and processing orders.
WooCommerce · PostgreSQL
SELECT to_char(p.post_date, 'YYYY-MM') AS month,
COUNT(*) AS orders,
ROUND(SUM(CAST(tot.meta_value AS DECIMAL(12,2))), 2) AS revenue
FROM wp_posts p
JOIN wp_postmeta tot
ON p.ID = tot.post_id AND tot.meta_key = '_order_total'
WHERE p.post_type = 'shop_order'
AND p.post_status IN ('wc-completed', 'wc-processing')
GROUP BY month
ORDER BY month DESC
LIMIT 24;How it works
Sums the _order_total meta of orders in revenue-bearing statuses, bucketed by the order date. Classic post-based schema.
Run this on your own database
BeQuery mirrors your WooCommerce MySQL database to an isolated PostgreSQL copy, so you can run queries like this one without ever touching production.
Start free No credit card