The title might not be exactly to the point, so let try to explain in detail my problem.
Let us say that I extract and sum data using the following query:
TRANSFORM Sum(tblTest.Value) AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
The data is all stored in price level 2010, and I now need to calculate the sum in price level 2011.
I would then have a small function which defines the multiplicator, and apply it like so:
TRANSFORM Sum(tblTest.Value)*GetPriceLevel() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
And this brings us to my problem.
tblTest.ExpenseType can be one of two values (i.e. 'Salary' and 'Expenses'), and each of them has its own multiplicator in order to calculate the price level.
Currently I add the multiplicator in two different queries - and get two recordsets:
TRANSFORM Sum(tblTest.Value)*GetPriceLevelSalary() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
WHERE tblTest.ExpenseType = 'Salary'
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
TRANSFORM Sum(tblTest.Value)*GetPriceLevelExpenses() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
WHERE tblTest.ExpenseType = 'Expenses'
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
The question would then be: Can this be done in one query? Giving me just one recordset.
Let us say that I extract and sum data using the following query:
TRANSFORM Sum(tblTest.Value) AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
The data is all stored in price level 2010, and I now need to calculate the sum in price level 2011.
I would then have a small function which defines the multiplicator, and apply it like so:
TRANSFORM Sum(tblTest.Value)*GetPriceLevel() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
And this brings us to my problem.
tblTest.ExpenseType can be one of two values (i.e. 'Salary' and 'Expenses'), and each of them has its own multiplicator in order to calculate the price level.
Currently I add the multiplicator in two different queries - and get two recordsets:
TRANSFORM Sum(tblTest.Value)*GetPriceLevelSalary() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
WHERE tblTest.ExpenseType = 'Salary'
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
TRANSFORM Sum(tblTest.Value)*GetPriceLevelExpenses() AS SumOfValue
SELECT tblTest.ExpenseType
FROM tblTest
WHERE tblTest.ExpenseType = 'Expenses'
GROUP BY tblTest.ExpenseType
PIVOT tblTest.Year;
The question would then be: Can this be done in one query? Giving me just one recordset.