|
- StrSQL = ""
- StrSQL = StrSQL & "SELECT 产品名称"
- StrSQL = StrSQL & ",SUM(到货数量) AS 到货总数"
- StrSQL = StrSQL & ",SUM(订单数量) AS 订单总数"
- StrSQL = StrSQL & ",SUM(退货数量) AS 退货总数"
- StrSQL = StrSQL & " FROM ("
-
- StrSQL = StrSQL & "SELECT 产品名称"
- StrSQL = StrSQL & ",到货数量"
- StrSQL = StrSQL & ",0 AS 订单数量"
- StrSQL = StrSQL & ",0 AS 退货数量"
- StrSQL = StrSQL & " FROM [" & SH0.Name & "$A2:B]"
- StrSQL = StrSQL & " UNION ALL "
- StrSQL = StrSQL & "SELECT 产品名称"
- StrSQL = StrSQL & ",0 AS 到货数量"
- StrSQL = StrSQL & ",订单数量"
- StrSQL = StrSQL & ",0 AS 退货数量"
- StrSQL = StrSQL & " FROM [" & SH0.Name & "$D2:E]"
- StrSQL = StrSQL & " UNION ALL "
- StrSQL = StrSQL & "SELECT 产品名称"
- StrSQL = StrSQL & ",0 AS 到货数量"
- StrSQL = StrSQL & ",0 AS 订单数量"
- StrSQL = StrSQL & ",退货数量"
- StrSQL = StrSQL & " FROM [" & SH0.Name & "$G2:H]"
- StrSQL = StrSQL & ") WHERE NOT 产品名称 IS NULL AND LEN(产品名称)>0"
- StrSQL = StrSQL & " GROUP BY 产品名称"
复制代码 |
|