Mysql pivot查询行和列 [英] Mysql pivot query rows and column

查看:76
本文介绍了Mysql pivot查询行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据以
形式保存。


 id day batch 
1 Nov1 A
2 11月B
3 Nov3 A
4月4日C
5 Nov1 B
6 Nov2 A
....
....







我想以


$ b的形式展示它$ b

 Nov1 Nov2 Nov3 Nov4 
ABAC
BA





这意味着我的行和列是动态的,因为没有天数没有限制相同没有批次也增加

在枢轴中我如何转置它感谢

解决方案

Hope这个链接可以帮到你:



http://www.kodyaz.com/articles/t-sql-pivot-tables-in-sql-server-tutorial-with-examples.aspx [ ^ ]

经常有问题...



看看这里:

MySQL中的数据库示例 [ ^ ]

MySQL中的数据透视表 [ ^ ]

与MySQL的交叉制表(数据透视表) [ ^ ]


I have data which is saved in the form of

id  day  batch
1  Nov1  A
2  Nov2  B
3  Nov3  A
4  Nov4  C
5  Nov1  B
6  Nov2  A
....
....




I want to show it in the form of

Nov1 Nov2 Nov3 Nov4
A    B    A    C
B    A



It mean my rows and columns are dynamic as no of days are not limited same as no of batches also increased
In pivot how i transpose it thanks

解决方案

Hope this link might help you:

http://www.kodyaz.com/articles/t-sql-pivot-tables-in-sql-server-tutorial-with-examples.aspx[^]


It's quite often question...

Have a look here:
Pivot tables example in MySQL[^]
Pivot tables in MySQL[^]
Cross-Tabulation (Pivot Tables) with MySQL[^]


这篇关于Mysql pivot查询行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆