假设有这样一个虚构的查询:
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"等)对这些条目进行分组?