|
access 数据库中有sheet1表和3个查询"1","2","总"
"1"的内容如下:
SELECT sheet1.Name, Sum(IIf(sheet1.购买日期,1,0)) AS 购买量
FROM sheet1
WHERE (((sheet1.购买日期)>=[QS] And (sheet1.购买日期)<=[JS]))
GROUP BY sheet1.Name;
"2"的内容如下:
SELECT sheet1.Name, Sum(IIf(sheet1.使用日期,1,0)) AS 使用量
FROM sheet1
WHERE sheet1.使用日期>=[QS] And sheet1.使用日期<=[JS]
GROUP BY sheet1.Name;
"总"的内容如下:
SELECT [1].Name, [1].购买量, [2].使用量
FROM 1 LEFT JOIN 2 ON [1].Name = [2].Name;
现在我想在vba中调用"总",请问代码如何写?
我目前是sql = "SELECT [1].Name, [1].购买量, [2].使用量 FROM 1 LEFT JOIN 2 ON [1].Name = [2].Name"
可是会报错,至少缺少一个参数。
求教了,谢谢
|
|