Du kan använda case
:
SELECT (CASE WHEN plan_type LIKE 'silver%' THEN 'silver'
WHEN plan_type LIKE 'gold%' THEN 'gold'
WHEN plan_type LIKE 'platinum%' THEN 'platinum'
END) as plan_grp, COUNT(*)
FROM subscriptions
GROUP by (CASE WHEN plan_type LIKE 'silver%' THEN 'silver'
WHEN plan_type LIKE 'gold%' THEN 'gold'
WHEN plan_type LIKE 'platinum%' THEN 'platinum'
END);
Vissa databaser låter dig använda ett kolumnalias i GROUP BY
.