Dim sdt As DataTable = DataTables("加油申请表")
Dim max As Integer = 0
For Each ary() As String In sdt.GetValues("车型|牌照号")
Dim c As Integer = sdt.Compute("count(车型)", "车型 = '" & ary(0) & "' and 牌照号 = '" & ary(1) & "'")
If c > max Then max = c
Next
Dim dtb As New DataTableBuilder("交叉表")
dtb.AddDef("车型", Gettype(String), 32)
dtb.AddDef("牌照号", Gettype(String), 32)
For i As Integer = 1 To max
dtb.AddDef("日期" & i, Gettype(Date),"","日期")
dtb.AddDef("数量" & i, Gettype(Double),"","数量")
Next
dtb.Build()
Dim dt As DataTable = DataTables("交叉表")
For Each ary() As String In sdt.GetValues("车型|牌照号")
Dim idx As Integer = 1
Dim ndr As DataRow = dt.AddNew
ndr("车型") = ary(0)
ndr("牌照号") = ary(1)
For Each dr As DataRow In sdt.Select("车型 = '" & ary(0) & "' and 牌照号 = '" & ary(1) & "'")
ndr("日期" & idx) = dr("日期")
ndr("数量" & idx) = dr("数量")
idx += 1
Next
Next