M
merry_fay
Hi,
First of all, I'd like to apologise for posting so much code, but
unfortunately without seeing it, it's probably difficult to work out what's
happening
I'm trying to build a union query which I will later drop into some code,
but I'm having problems with the error message 'system resource exceeded' or
if I tweak a couple of speech marks (toggle text/numbers) 'Query Too Complex'
SELECT [Budget TPID].TSL, [Budget TPID].Application, [Budget TPID].[Business
Service], [Budget TPID].TPID, Null AS Project, [Unit Price].Co,
Sum([jan]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 1,
Sum([feb]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 2,
Sum([mar]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 3,
Sum([apr]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 4,
Sum([may]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 5,
Sum([jun]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 6,
Sum([jul]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 7,
Sum([aug]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 8,
Sum([sep]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 9,
Sum([oct]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 10,
Sum([nov]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 11,
Sum([dec]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 12,
[Budget TPID].Classification, [Unit Price].Year, [Unit Price].UPVsn, 1.1 AS
[Unique]
FROM [Unit Price] INNER JOIN [Budget TPID] ON ([Unit Price].Version =
[Budget TPID].Version) AND ([Unit Price].Year = [Budget TPID].Year) AND
([Unit Price].TPID = [Budget TPID].TPID) AND ([Unit Price].TSL = [Budget
TPID].TSL) AND ([Unit Price].Application = [Budget TPID].Application) AND
([Unit Price].[Business Service] = [Budget TPID].[Business Service]) AND
([Unit Price].Co = [Budget TPID].Co) AND ([Unit Price].Classification =
[Budget TPID].Classification)
GROUP BY [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [Unit Price].Co, [Budget
TPID].Classification, [Unit Price].Year, [Unit Price].UPVsn, null
HAVING ((([Unit Price].Year)='2010') AND (([Unit Price].UPVsn)=1.1))
UNION ALL SELECT [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [1- CostingData].Project,
[Budget TPID].Co,
Sum([jan]*[charge]), Sum([feb]*[charge]), Sum([mar]*[charge]),
Sum([apr]*[charge]), Sum([may]*[charge]), Sum([jun]*[charge]),
Sum([jul]*[charge]), Sum([aug]*[charge]), Sum([sep]*[charge]),
Sum([oct]*[charge]), Sum([nov]*[charge]), Sum([dec]*[charge]),
[Budget TPID].Classification, [Budget TPID].Year, 1.1, 1.1
FROM [Budget TPID] INNER JOIN [1- CostingData] ON ([Budget TPID].TSL = [1-
CostingData].TSL) AND ([Budget TPID].Co = [1- CostingData].Co)
WHERE [1- CostingData].TPID Is Null
GROUP BY [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [1- CostingData].Project,
[Budget TPID].Co, [Budget TPID].Classification, [Budget TPID].Year, 1.1, 1.1
HAVING [1- CostingData].Project Is Null AND [Budget TPID].Classification="D"
UNION ALL SELECT TSL, 'xxx', 'xxx', TPID, Project, Co, sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), 'M', 2010, 1.1, 1.1
FROM [1- CostingData]
GROUP BY TSL, TPID, Project, Co
HAVING TPID Is Not Null AND Project Is Null;
Both Budget TPID & Unit Price are tables & 1 -Costing Data is a union query
itself.
The 1st & 3rd, & 1st & 2nd queries work together & all work individually,
but I can't run all 3 parts together or just the 2nd & 3rd.
Any suggestions?
The 1st 2 parts bring back 1378 rows of data & the 3rd part 41 rows!
Thanks
merry_fay
First of all, I'd like to apologise for posting so much code, but
unfortunately without seeing it, it's probably difficult to work out what's
happening
I'm trying to build a union query which I will later drop into some code,
but I'm having problems with the error message 'system resource exceeded' or
if I tweak a couple of speech marks (toggle text/numbers) 'Query Too Complex'
SELECT [Budget TPID].TSL, [Budget TPID].Application, [Budget TPID].[Business
Service], [Budget TPID].TPID, Null AS Project, [Unit Price].Co,
Sum([jan]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 1,
Sum([feb]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 2,
Sum([mar]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 3,
Sum([apr]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 4,
Sum([may]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 5,
Sum([jun]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 6,
Sum([jul]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 7,
Sum([aug]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 8,
Sum([sep]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 9,
Sum([oct]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 10,
Sum([nov]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 11,
Sum([dec]*IIf(Override=0,[Unit Cost/Charge],Override)) AS 12,
[Budget TPID].Classification, [Unit Price].Year, [Unit Price].UPVsn, 1.1 AS
[Unique]
FROM [Unit Price] INNER JOIN [Budget TPID] ON ([Unit Price].Version =
[Budget TPID].Version) AND ([Unit Price].Year = [Budget TPID].Year) AND
([Unit Price].TPID = [Budget TPID].TPID) AND ([Unit Price].TSL = [Budget
TPID].TSL) AND ([Unit Price].Application = [Budget TPID].Application) AND
([Unit Price].[Business Service] = [Budget TPID].[Business Service]) AND
([Unit Price].Co = [Budget TPID].Co) AND ([Unit Price].Classification =
[Budget TPID].Classification)
GROUP BY [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [Unit Price].Co, [Budget
TPID].Classification, [Unit Price].Year, [Unit Price].UPVsn, null
HAVING ((([Unit Price].Year)='2010') AND (([Unit Price].UPVsn)=1.1))
UNION ALL SELECT [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [1- CostingData].Project,
[Budget TPID].Co,
Sum([jan]*[charge]), Sum([feb]*[charge]), Sum([mar]*[charge]),
Sum([apr]*[charge]), Sum([may]*[charge]), Sum([jun]*[charge]),
Sum([jul]*[charge]), Sum([aug]*[charge]), Sum([sep]*[charge]),
Sum([oct]*[charge]), Sum([nov]*[charge]), Sum([dec]*[charge]),
[Budget TPID].Classification, [Budget TPID].Year, 1.1, 1.1
FROM [Budget TPID] INNER JOIN [1- CostingData] ON ([Budget TPID].TSL = [1-
CostingData].TSL) AND ([Budget TPID].Co = [1- CostingData].Co)
WHERE [1- CostingData].TPID Is Null
GROUP BY [Budget TPID].TSL, [Budget TPID].Application, [Budget
TPID].[Business Service], [Budget TPID].TPID, [1- CostingData].Project,
[Budget TPID].Co, [Budget TPID].Classification, [Budget TPID].Year, 1.1, 1.1
HAVING [1- CostingData].Project Is Null AND [Budget TPID].Classification="D"
UNION ALL SELECT TSL, 'xxx', 'xxx', TPID, Project, Co, sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), sum([Charge]/12),
sum([Charge]/12), sum([Charge]/12), sum([Charge]/12), 'M', 2010, 1.1, 1.1
FROM [1- CostingData]
GROUP BY TSL, TPID, Project, Co
HAVING TPID Is Not Null AND Project Is Null;
Both Budget TPID & Unit Price are tables & 1 -Costing Data is a union query
itself.
The 1st & 3rd, & 1st & 2nd queries work together & all work individually,
but I can't run all 3 parts together or just the 2nd & 3rd.
Any suggestions?
The 1st 2 parts bring back 1378 rows of data & the 3rd part 41 rows!
Thanks
merry_fay