Dim cmd As New SQLCommandDim dt As DataTable
cmd.CommandText = "SELECT 商品编号,颜色,规格,sum(数量) As 数量,单位 From(SELECT 商品编号,颜色,规格, 数量, 单位 FROM {销售明细} UNION SELECT 商品编号,颜色,规格,-数量,单位 FROM {退货明细}) GROUP BY 商品编号,颜色,规格,单位"dt = cmd.ExecuteReader()
Tables("任意表").DataSource = dt