字符类的表格如何转置?
此主题相关图片如下:捕获.png
如图,我是参考
垂直表和水平表的转换
这一章节
里面是用了sum,但是我的表格都是字符。而且原始表格是纵排列,1列测试项目,一列结论。每个批号的测试项目都有不同。如何将其横向排列?
combolis = DataTables("数据").SQLGetValues("批号", "结论 Like '%" & namelist & "%'") '得到所选批号
ae = combolis.ToArray()
lis = "'" & String.join("','", ae) & "'" '批号加工成串
combolis = DataTables("QC数据").SQLGetValues("测试项", "批号 in (" & lis & ")") '得到所选测试项
ae = combolis.ToArray()'测试项加工成串
Dim t, t1 As String
For Each tes As String In ae
t = t & "Case When 测试项 = '" & tes & "' Then 结论 Else null End, "
Next
t = t.Trim(",")
t1 = "Slect 检验单号," & t & " From {QC数据} where 批号 in (" & lis & ")"
MessageBox.Show(t1)
Dim q As New QueryBuilder
q.TableName = "QC数据表"