0
+---------+--------------------+-----------+
| id | reason | location |
+---------+--------------------+-----------+
| 1077501 | credit_card | AZ |
| 1077430 | car | GA |
| 1077175 | small_business | IL |
| 1076863 | other | CA |
| 1075358 | other | OR |
| 1075269 | wedding | AZ |
| 1069639 | debt_consolidation | NC |
| 1072053 | car | CA |
| 1071795 | small_busines | CA |
+---------+--------------------+-----------+
输出应该是
+----------+-------------+-----+----------------+----------+---------+-------+
| location | credit_card | car | small_business | other... | wedding | total |
+----------+-------------+-----+----------------+----------+---------+-------+
| AZ | 1 | 0 | 0 | 0 | 1 | 2 |
| CA | 0 | 1 | 1 | 0 | 0 | 2 |
+----------+-------------+-----+----------------+----------+---------+-------+
输出应在上述格式原因为每个位置作为一列。
你尝试过什么?这是一个基本的东西不应该很难。 – Hogan
是的,我已经尝试过,但理由cloumn值应该动态转换为列我只能为少数值。 。 – Manish
下面的答案适用。 –