|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Dim myData As New Data查询
Dim sql As String, sql1 As String, sql2 As String, sql3 As String, sql4 As String
sql2 = "Select 客户,电话,sum(销售金额) as 合计 from chuku Where(付款)='" & Cells(1, "h") & "' group by 客户,电话"
sql3 = "Select 客户,电话,sum(合计) from(" & sql2 & ") as 合计 group by 客户,电话"
sql = "Select 客户,电话,欠款 as 金额 from chuku Where(付款)='" & Cells(1, "h") & "' group by 客户,电话,欠款"
sql1 = "Select 客户,电话,sum(金额) from(" & sql & ") as 金额 group by 客户,电话"
sql4 = "select 客户,电话,sum(合计),(sum(合计)-sum(金额)) as 已付,SUM(金额) from (" & sql3 & ") as 合计 left join (" & sql1 & ") as 金额 group by 客户,电话 "
myData.执行筛选 sql4, "b3"
错误出在sql4里,”from子句语法错误”
|
|