如何使用sql squery获得以下输出 [英] How to get the below output using sql squery
问题描述
在表中记录如下
Facid Q1 Q2 Q3 Batchid
1 2 3 4 B001
2 4 4 5 B001
1 5 1 2 B002
2 4 5 3 B002
1 4 1 2 B003
2 5 4 3 B003
使用以上记录我希望使用sql查询输出如下
B001 B002 B003
Facid Q1 Q2 Q3 Q1 Q2 Q3 Q1 Q2 Q3
1 2 3 4 5 1 2 4 1 2 >
2 4 4 5 4 5 3 5 4 3
获得以上输出我如何编写SQL查询。
请帮助我。使用数据库我怎样才能使用sql查询。
问候
Narasiman
试试这个
在SQL查询中使用Pivot的简单方法 [ ^ ]
SQL - 使用Grand Total Column和Pivot行 [ ^ ]
仍然不确定是否可以按照您的要求带双头。
希望这会有所帮助
问候,
Dinesh Kumar.V。
In table records as follows
Facid Q1 Q2 Q3 Batchid
1 2 3 4 B001
2 4 4 5 B001
1 5 1 2 B002
2 4 5 3 B002
1 4 1 2 B003
2 5 4 3 B003
Using above records i want output as follows using sql query
B001 B002 B003
Facid Q1 Q2 Q3 Q1 Q2 Q3 Q1 Q2 Q3
1 2 3 4 5 1 2 4 1 2
2 4 4 5 4 5 3 5 4 3
for getting a above output how can i write a sql query.
kindly please help me.using pivot how can i do using sql query.
Regards
Narasiman
Try this
Simple Way To Use Pivot In SQL Query[^]
SQL - Pivot with Grand Total Column and Row[^]
Still am not sure if it is possible to bring double header as you had requested.
Hope this helps
Regards,
Dinesh Kumar.V.
这篇关于如何使用sql squery获得以下输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!