Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
A | 2 |
A | 3 |
B | 2 |
B | 4 |
D | 3 |
A | 5 |
B | 6 |
D | 3 |
A | B | C | D | E |
Dim cmd As New SQLCommand
Dim 统计表A As DataTable
cmd.CommandText = "Select 第一列 , Sum(第二列) AS 第二列 From {表A} Group by 第一列"
统计表A = cmd.ExecuteReader()
Dim dt As Table = Tables("表B")
Dim dt1 As DataTable = DataTables("表A")
Dim ColNames() As String = {"A","B","C","D","E"}
For Each ColName As String In ColNames
Dim Value As Integer
Value = dt1.Compute("sum(第二列)","[第一列] = '" & ColName & "'")
dt.Rows(0)(ColName) = Value
Next
Dim cmd As New SQLCommand
Dim 统计表A As DataTable
cmd.CommandText = "Select 第一列 , Sum(第二列) AS 第二列 From {表A} Group by 第一列"
统计表A = cmd.ExecuteReader()
Dim ColNames() As String = {"A","B","C","D","E"}
For Each ColName As String In ColNames
Tables("表B").Rows(0)(ColName) = DataTables("表A").Compute("sum(第二列)","[第一列] = '" & ColName & "'")+0
Next