Customer lifetime value in WooCommerce
Average lifetime spend per WooCommerce customer (by billing email).
WooCommerce · PostgreSQL
SELECT ROUND(AVG(spent), 2) AS avg_lifetime_value
FROM (
SELECT em.meta_value AS email, SUM(CAST(tot.meta_value AS DECIMAL(12,2))) AS spent
FROM wp_posts p
JOIN wp_postmeta tot ON p."ID" = tot.post_id AND tot.meta_key = '_order_total'
JOIN wp_postmeta em ON p."ID" = em.post_id AND em.meta_key = '_billing_email'
WHERE p.post_type = 'shop_order'
AND p.post_status IN ('wc-completed', 'wc-processing')
GROUP BY em.meta_value
) x;How it works
Totals each customer's paid-order value by billing email, then averages — your average customer lifetime value. Works on the classic post-based schema without a customers table.
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