|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
SQL代码如下:
StrSQL = StrSQL & "SELECT x.工厂"
StrSQL = StrSQL & ",x.电话号码"
StrSQL = StrSQL & ",sum(x.合计) as 退厂件数"
StrSQL = StrSQL & ",sum(x.金额2) as 退厂金额"
StrSQL = StrSQL & ",未付"
'StrSQL = StrSQL & ",未付-退厂金额 as 厂家存放"
StrSQL = StrSQL & ",次品"
StrSQL = StrSQL & ",换色换码"
StrSQL = StrSQL & ",退版"
StrSQL = StrSQL & ",代修"
StrSQL = StrSQL & ",代卖"
StrSQL = StrSQL & ",0"
StrSQL = StrSQL & ",x.工厂情况"
StrSQL = StrSQL & " FROM ((((([" & SHkc.Name & "$A1:AT]x"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(结余金额) as 未付"
StrSQL = StrSQL & " FROM [" & SH0.Name & "$A1:K] GROUP BY 工厂)y"
StrSQL = StrSQL & " ON x.工厂=y.工厂)"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(金额2) as 次品"
StrSQL = StrSQL & " FROM [" & SHkc.Name & "$A1:AT]"
StrSQL = StrSQL & " WHERE 退厂类别='次品' GROUP BY 工厂)b"
StrSQL = StrSQL & " ON x.工厂=b.工厂)"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(金额2) as 换色换码"
StrSQL = StrSQL & " FROM [" & SHkc.Name & "$A1:AT]"
StrSQL = StrSQL & " WHERE 退厂类别='换色换码' GROUP BY 工厂)c"
StrSQL = StrSQL & " ON x.工厂=c.工厂)"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(金额2) as 退版"
StrSQL = StrSQL & " FROM [" & SHkc.Name & "$A1:AT]"
StrSQL = StrSQL & " WHERE 退厂类别='退版' GROUP BY 工厂)d"
StrSQL = StrSQL & " ON x.工厂=d.工厂)"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(金额2) as 代修"
StrSQL = StrSQL & " FROM [" & SHkc.Name & "$A1:AT]"
StrSQL = StrSQL & " WHERE 退厂类别='代修' GROUP BY 工厂)e"
StrSQL = StrSQL & " ON x.工厂=e.工厂)"
StrSQL = StrSQL & " left JOIN"
StrSQL = StrSQL & " (SELECT 工厂"
StrSQL = StrSQL & ",sum(金额2) as 代卖"
StrSQL = StrSQL & " FROM [" & SHkc.Name & "$A1:AT]"
StrSQL = StrSQL & " WHERE 退厂类别='代卖' GROUP BY 工厂)f"
StrSQL = StrSQL & " ON x.工厂=f.工厂"
StrSQL = StrSQL & " where 退厂金额>0 GROUP BY x.工厂,x.电话号码,未付,次品,换色换码,退版,代修,代卖,x.工厂情况"
运行报错,提示至少有一个参数没有被指定值。但是我找遍了也没发现问题。请老师指点,谢谢!!!!
|
|