SELECT a.权属, a.图斑, [地类1面积]+[地类2面积] AS 总面积, Sum(IIf([地类] Like 1,[面积],0)) AS 地类1面积, Sum(IIf([地类] Like 2,[面积],0)) AS 地类2面积
FROM (SELECT 表1.权属 AS 权属, 表1.图斑, 表2.地类, Max(CDbl(DSum("面积","表2","图斑='" & [表2.图斑] & "'and 地类='" & [地类] & "'and 编号<=" & [编号] & ""))) AS 面积
FROM 表1 RIGHT JOIN 表2 ON 表1.图斑 = 表2.图斑
GROUP BY 表1.权属, 表1.图斑, 表2.地类) AS a
GROUP BY a.权属, a.图斑
ORDER BY a.图斑;
SELECT a.权属, a.图斑, [地类1面积]+[地类2面积] AS 总面积, Sum(IIf([地类] Like 1,[面积],0)) AS 地类1面积, Sum(IIf([地类] Like 2,[面积],0)) AS 地类2面积
FROM (SELECT 表1.权属 AS 权属, 表1.图斑, 表2.地类, Max(CDbl(DSum("面积","表2","图斑='" & [表2.图斑] & "'and 地类='" & [地类] & "'and 编号<=" & [编号] & ""))) AS 面积
FROM 表1 RIGHT JOIN 表2 ON 表1.图斑 = 表2.图斑
GROUP BY 表1.权属, 表1.图斑, 表2.地类) AS a
GROUP BY a.权属, a.图斑
ORDER BY a.图斑;