WITH CustomerRatings AS (
SELECT
customer_id,
AVG(rating) AS avg_rating
FROM
wlmt_reviews
GROUP BY
customer_id
)
SELECT
CASE
WHEN avg_rating >= 4 THEN 'Promoter'
ELSE 'Neutral' END AS segment,
COUNT(*) AS customer_count,
ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM CustomerRatings),2) AS percentage
FROM
CustomerRatings
GROUP BY
segment
ORDER BY
percentage DESC;