B
BAC
VISTA Enterprise/Office 2007 Plus
situation:
Two identically structured tables, [Prior month] and [current month]
tables consist of contracts and assets with costs. there is a field that
indicates the unit count (i.e. the number of units on the contract)
Occassionally, the number of assets may increase from last month with no
increase in contract cost
Record:
[current month]
Contract Asset Cost units
1 1 5.00 3
1 2 4.00 3
1 3 3.00 3
[prior month]
1 1 8.00 2
1 2 4.00 2
objective:
Identify those items where the number of units assigned to a contract has
increased, but total contract cost has not.
I can isolate the contracts where the unit cnt has changed and get the
relevant cost numbers:
SELECT [current month].CONTRACT, [current month].ASSET, Max([prior
month].[UNITS]) AS [MaxOfUNITS], First([current month].[UNITS]) AS
[FirstOfUNITS], Avg([prior month].[COST]) AS [AvgOfCOST], Avg([current
month].[COST]) AS [AvgOfCOST1]
FROM [current month] INNER JOIN [prior month] ON [current month].CONTRACT =
[prior month].CONTRACT
WHERE ((([current month].[UNITS])>[prior month].[UNITS]))
GROUP BY [current month].CONTRACT, [current month].ASSET;
What I can't seem to figure out is how to limit on sum([prior month].[cost])
= sum([current month].[cost]). How do I add this limit without getting some
sort of "Aggregate in Where clause error? Now I'm getting all contracts where
the number of units has changed regardless of whether or not costs have
changed
TIA
BAC
situation:
Two identically structured tables, [Prior month] and [current month]
tables consist of contracts and assets with costs. there is a field that
indicates the unit count (i.e. the number of units on the contract)
Occassionally, the number of assets may increase from last month with no
increase in contract cost
Record:
[current month]
Contract Asset Cost units
1 1 5.00 3
1 2 4.00 3
1 3 3.00 3
[prior month]
1 1 8.00 2
1 2 4.00 2
objective:
Identify those items where the number of units assigned to a contract has
increased, but total contract cost has not.
I can isolate the contracts where the unit cnt has changed and get the
relevant cost numbers:
SELECT [current month].CONTRACT, [current month].ASSET, Max([prior
month].[UNITS]) AS [MaxOfUNITS], First([current month].[UNITS]) AS
[FirstOfUNITS], Avg([prior month].[COST]) AS [AvgOfCOST], Avg([current
month].[COST]) AS [AvgOfCOST1]
FROM [current month] INNER JOIN [prior month] ON [current month].CONTRACT =
[prior month].CONTRACT
WHERE ((([current month].[UNITS])>[prior month].[UNITS]))
GROUP BY [current month].CONTRACT, [current month].ASSET;
What I can't seem to figure out is how to limit on sum([prior month].[cost])
= sum([current month].[cost]). How do I add this limit without getting some
sort of "Aggregate in Where clause error? Now I'm getting all contracts where
the number of units has changed regardless of whether or not costs have
changed
TIA
BAC