我从一个表中得到以下3个查询。不同的是每个查询中的标准([ReceiptYesNo])。
Query No1 - NO Criteria:
TRANSFORM IIf(Sum([price]) Is Null,0,Sum([price])) AS SumPrice
SELECT Format([ExpensesDate],"yyyy") AS [Year], IIf(Sum([SumPrice]) Is Null,0,Sum([SumPrice])) AS TotalPricePerYear
FROM tblExpenses
GROUP BY Format([ExpensesDate],"yyyy")
ORDER BY Format([ExpensesDate],"yyyy") DESC
PIVOT Month([ExpensesDate]) In (1,2,3,4,5,6,7,8,9,10,11,12);
Query No2 - Criteria [ReceiptYesNo] = YES:
TRANSFORM IIf(Sum([price]) Is Null,0,Sum([price])) AS SumPrice
SELECT Format([ExpensesDate],"yyyy") AS [Year], IIf(Sum([SumPrice]) Is Null,0,Sum([SumPrice])) AS TotalPricePerYear
FROM tblExpenses
WHERE (((tblExpenses.ReceiptYesNo)="YES")) <=== See Here ===
GROUP BY Format([ExpensesDate],"yyyy")
ORDER BY Format([ExpensesDate],"yyyy") DESC
PIVOT Month([ExpensesDate]) In (1,2,3,4,5,6,7,8,9,10,11,12);
Query No3 - Criteria [ReceiptYesNo] = NO:
TRANSFORM IIf(Sum([price]) Is Null,0,Sum([price])) AS SumPrice
SELECT Format([ExpensesDate],"yyyy") AS [Year], IIf(Sum([SumPrice]) Is Null,0,Sum([SumPrice])) AS TotalPricePerYear
FROM tblExpenses
WHERE (((tblExpenses.ReceiptYesNo)="NO")) <=== See Here ===
GROUP BY Format([ExpensesDate],"yyyy")
ORDER BY Format([ExpensesDate],"yyyy") DESC
PIVOT Month([ExpensesDate]) In (1,2,3,4,5,6,7,8,9,10,11,12);
是否可以创建一个包含3?
的查询谢谢。