如何为重复值创建列?

时间:2019-12-16 22:46:21

标签: mysql pivot-table

我有这张桌子:

+---------+------------+-------+
| Name    | Date       | Debt  |
+---------+------------+-------+
| Michael | 2019-01-01 | 29.9  |
+---------+------------+-------+
| Sarah   | 2019-01-01 | 9.99  |
+---------+------------+-------+
| Michael | 2019-01-02 | 10.99 |
+---------+------------+-------+
| Sarah   | 2019-01-02 | 12.99 |
+---------+------------+-------+

我想创建这样的东西:

+---------+---------+----------+-------+
| Name    | January | February | Total |
+---------+---------+----------+-------+
| Michael | 29.9    | 10.99    | 40.89 |
+---------+---------+----------+-------+
| Sarah   | 9.99    | 12.99    | 22.98 |
+---------+---------+----------+-------+

我尝试使用内部联接并使用AS关键字。

0 个答案:

没有答案