PostgreSQL枢轴表
我有这种类型的桌子,我想转换:
这种表:
customer_name product_type total_paid
Lian car 100
Lian motorbike 200
Carl car 300
Carl motorbike 500
在另一个表格中:
customer_name car motorbike
Lian 100 200
Carl 300 500
使用PostgreSQL,如果有人可以帮助我,我真的很感激。
I have this type of table and I'd like to convert:
This kind of table:
customer_name product_type total_paid
Lian car 100
Lian motorbike 200
Carl car 300
Carl motorbike 500
In this other kind of table:
customer_name car motorbike
Lian 100 200
Carl 300 500
Using Postgresql, I would really appreciate if someone can help me please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用组和总和函数。
You can use a group by and the SUM aggregate function.
尝试以下操作:
Try this: