给出一个假设的查询,例如:
SELECT COUNT(*)
FROM subscriptions
GROUP by plan_type
和下面的表类似:
+----+-----------------------+-------------+--+
| id | plan_type | customer_id | |
+----+-----------------------+-------------+--+
| 1 | gold_2017 | 523 | |
| 2 | gold_2016_recurring | 2300 | |
| 3 | silver_2016 | 234 | |
| 4 | silver_2017_recurring | 2593 | |
| 5 | platinum_recurring | 4123 | |
+----+-----------------------+-------------+--+
期望的结果:
+-------+----------+
| count | type |
+-------+----------+
| 2 | gold |
| 2 | silver |
| 1 | platinum |
+-------+----------+
有没有办法使用GROUP BY和LIKE语句对这些条目进行分组(LIKE“silver”,LIKE“gold”,LIKE“platinum”等)?