Query too Complex...

T

Tara

words I have seen way too much of today! And if it is not "too compex" then I
get a message saying "insufficient resources".

I have spent the day trying to break up boards into smaller sections and
trying to find other ways to get the same answer. Eventually I have to bring
the seperated boards back together again, so the end result is still the
same: Query is too complex

Does anyone have a suggestion that I could try to get around these
frustrating comments? Should I be using subqueries? - would that help
simplify things in the FROM clause?

Tara
 
T

Tara

Okay...here is an example, but I will have to show you the boards leading up
to the last one as well:

Query1
SELECT [MVA].[Yr], [AA].[Cn], [MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*0.95)/1000000
AS [Ee], [Ee]*[MVA]![Cx] AS [Ff],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd]) AS
[Kk], [Kk]*[MVA]![Cx] AS [Ll],
([MCA]![Mm]*[AA]![Ii]/1000000)-(([AA]![Cc]-[AA]![Ii]-0.95*[AA]![Dd])*50/1000000)
AS [Nn], [Nn]*[MVA]![Cx] AS [Oo], [Ee]+[Kk]+[Nn] AS [Pp], [Pp]*[MVA]![Cx] AS
[Rr]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query2
SELECT [MVA].[Yr], [AA].[Cn], [AA]![Dd]*[MVA]![Bb]/1000000 AS [Ss],
[Ss]*[MVA]![Cx] AS [Tt],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)-([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd])
AS [Uu], [Uu]*[MVA]![Cx] AS [Vv], [MCA]![Ww]*[AA]![Dd]/1000000 AS [Xx],
[Xx]*[MVA]![Cx] AS [Yy], [Ss]+[Uu]+[Xx] AS [Zz], [Zz]*[MVA]![Cx] AS [Ab]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query3
SELECT [MVA].[Yr], [Ac].[Cn], [Ad]/[MVA]![Cx] AS [Ae],
[Af]![Ag]*[Af]![Ah]/1000000 AS [Ad]
FROM [MVA] INNER JOIN ([Ac] INNER JOIN [Af] ON [Ac].[Cn] = [Af].[Cn]) ON
[MVA].[Yr] = [Af].[Yr];


Query4
SELECT [MVA].[Yr], [AK].[Cn],
([Al]![Am]*[MVA]![Bb]/1000000)-([AK]![An]*[Ao]![Ap]/1000000) AS [Ar],
[Ar]*[MVA]![Cx] AS [As],
((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax]))*0.85)*([MVA]![Ay]/1000000)-((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax])/[AK]![Az])*([Ao]![Ba]/1000000))
AS [Bc], [Bc]*[MVA]![Cx] AS [Bd], [Be]/[MVA]![Cx] AS [Bf],
([Bg]![Bh]/([AK]![Bk]/[AK]![Bl]))*(([AK]![Bk]/[AK]![Bl])/0.01)*75*([MVA]![Bb]/1000)/1000000
AS [Be], ([Bm]![Bn]*([MVA]![Bb]/1000000))-([Bm]![Bo]*([Ao]![Ap]/1000000)) AS
[Bp],
([Bp]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*Bx![By]/1000000)
AS [Bz], ([Ca]![Bn]*([MVA]![Bb]/1000000))-([Ca]![Bo]*([Ao]![Ap]/1000000)) AS
[Cb],
([Cb]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*[Ca]![Cd]/1000000)
AS [Ce], [Cf]/[MVA]![Cx] AS [Cg], [As]+[Bd]+[Be]+[Bz]+[Ce] AS [Cf],
[Ch]/[MVA]![Cx] AS [Ck], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch], [Cl]/[MVA]![Cx] AS [Cm],
[Cf]+[Ch] AS [Cl]
FROM [MCA], ((((((([MVA] INNER JOIN (([AK] INNER JOIN [Al] ON [AK].[Cn] =
[Al].[Cn]) INNER JOIN [Ao] ON [Al].[Yr] = [Ao].[Yr]) ON [MVA].[Yr] =
[Al].[Yr]) INNER JOIN ([Au] INNER JOIN [Bg] ON ([Au].[Yr] = [Bg].[Yr]) AND
([Au].[Cn] = [Bg].[Cn])) ON ([Ao].[Yr] = [Au].[Yr]) AND ([Al].[Cn] =
[Au].[Cn])) INNER JOIN [Bm] ON ([Bg].[Yr] = [Bm].[Yr]) AND ([Bg].[Cn] =
[Bm].[Cn])) INNER JOIN [Ac] ON [Bm].[Cn] = [Ac].[Cn]) INNER JOIN [Bu] ON
[Ac].[Cn] = [Bu].[Cn]) INNER JOIN Bx ON [Bu].[Cn] = Bx.[Cn]) INNER JOIN Laos
ON Bx.[Cn] = Laos.[Cn]) INNER JOIN [Ca] ON (Laos.[Cn] = [Ca].[Cn]) AND
([Bm].[Yr] = [Ca].[Yr]);


Query5
SELECT [MVA].[Yr], [AA].[Cn],
([MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*(0.95)+[AA]![Dd]-[AA]![Gg])+[AA]![Gg]*[AA]![Hh]+[MCA]![Mm]*[AA]![Ii]-50*([AA]![Cc]-[AA]![Ii]-[AA]![Dd]*(0.95))+[MCA]![Ww]*[AA]![Dd])/1000000
AS [Co], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch],
(([Af]![Ag]*[Af]![Ah]/1000000)+[Ch])/[MVA]![Cx]+[Co] AS [Cp]
FROM [MCA], ([MVA] INNER JOIN [AA] ON [MVA].[Yr]=[AA].[Yr]) INNER JOIN [Af]
ON ([AA].[Yr]=[Af].[Yr]) AND ([AA].[Cn]=[Af].[Cn]);


Query6
SELECT [Query5].[Yr], [Query5].[Cn], [Query5].[Cp], [Query5]![Cp]*[MVA]![Cx]
AS [Cr]
FROM ([Query5] INNER JOIN [MVA] ON [Query5].[Yr] = [MVA].[Yr]) INNER JOIN
[Ao] ON [MVA].[Yr] = [Ao].[Yr];


Query7
SELECT [Query4].[Yr], [Query4].[Cn], [Query4].[Cg], [Query4].[Cf],
[Query4]![Cg]+[Query6]![Cp] AS ConUSD, [Query4]![Cf]+[Query6]![Cr] AS ConTHB,
[Query6].[Cp], [Query6].[Cr]
FROM [Query4], [Query6];


Notes:
- Query4 is so long because I had to rebuild all the formulas from scratch
otherwise I would get “Query too complexâ€
- Query6 should ideally be included in Query5, but I would get a message
saying “Query too complexâ€. It would only work if I put it into a new query.
- I cannot get Query7 to work. The different boards cannot be put into one
query.
- Ideally, the information on Queries 5,6,&7 should all be one query.

I know this is very long, but I couldn’t show you just Query7 without
showing you what precedes it.
Any suggestions?
 
K

Klatuu

Sorry, Tara, there is so much there I can't tell by just looking.
--
Dave Hargis, Microsoft Access MVP


Tara said:
Okay...here is an example, but I will have to show you the boards leading up
to the last one as well:

Query1
SELECT [MVA].[Yr], [AA].[Cn], [MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*0.95)/1000000
AS [Ee], [Ee]*[MVA]![Cx] AS [Ff],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd]) AS
[Kk], [Kk]*[MVA]![Cx] AS [Ll],
([MCA]![Mm]*[AA]![Ii]/1000000)-(([AA]![Cc]-[AA]![Ii]-0.95*[AA]![Dd])*50/1000000)
AS [Nn], [Nn]*[MVA]![Cx] AS [Oo], [Ee]+[Kk]+[Nn] AS [Pp], [Pp]*[MVA]![Cx] AS
[Rr]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query2
SELECT [MVA].[Yr], [AA].[Cn], [AA]![Dd]*[MVA]![Bb]/1000000 AS [Ss],
[Ss]*[MVA]![Cx] AS [Tt],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)-([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd])
AS [Uu], [Uu]*[MVA]![Cx] AS [Vv], [MCA]![Ww]*[AA]![Dd]/1000000 AS [Xx],
[Xx]*[MVA]![Cx] AS [Yy], [Ss]+[Uu]+[Xx] AS [Zz], [Zz]*[MVA]![Cx] AS [Ab]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query3
SELECT [MVA].[Yr], [Ac].[Cn], [Ad]/[MVA]![Cx] AS [Ae],
[Af]![Ag]*[Af]![Ah]/1000000 AS [Ad]
FROM [MVA] INNER JOIN ([Ac] INNER JOIN [Af] ON [Ac].[Cn] = [Af].[Cn]) ON
[MVA].[Yr] = [Af].[Yr];


Query4
SELECT [MVA].[Yr], [AK].[Cn],
([Al]![Am]*[MVA]![Bb]/1000000)-([AK]![An]*[Ao]![Ap]/1000000) AS [Ar],
[Ar]*[MVA]![Cx] AS [As],
((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax]))*0.85)*([MVA]![Ay]/1000000)-((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax])/[AK]![Az])*([Ao]![Ba]/1000000))
AS [Bc], [Bc]*[MVA]![Cx] AS [Bd], [Be]/[MVA]![Cx] AS [Bf],
([Bg]![Bh]/([AK]![Bk]/[AK]![Bl]))*(([AK]![Bk]/[AK]![Bl])/0.01)*75*([MVA]![Bb]/1000)/1000000
AS [Be], ([Bm]![Bn]*([MVA]![Bb]/1000000))-([Bm]![Bo]*([Ao]![Ap]/1000000)) AS
[Bp],
([Bp]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*Bx![By]/1000000)
AS [Bz], ([Ca]![Bn]*([MVA]![Bb]/1000000))-([Ca]![Bo]*([Ao]![Ap]/1000000)) AS
[Cb],
([Cb]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*[Ca]![Cd]/1000000)
AS [Ce], [Cf]/[MVA]![Cx] AS [Cg], [As]+[Bd]+[Be]+[Bz]+[Ce] AS [Cf],
[Ch]/[MVA]![Cx] AS [Ck], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch], [Cl]/[MVA]![Cx] AS [Cm],
[Cf]+[Ch] AS [Cl]
FROM [MCA], ((((((([MVA] INNER JOIN (([AK] INNER JOIN [Al] ON [AK].[Cn] =
[Al].[Cn]) INNER JOIN [Ao] ON [Al].[Yr] = [Ao].[Yr]) ON [MVA].[Yr] =
[Al].[Yr]) INNER JOIN ([Au] INNER JOIN [Bg] ON ([Au].[Yr] = [Bg].[Yr]) AND
([Au].[Cn] = [Bg].[Cn])) ON ([Ao].[Yr] = [Au].[Yr]) AND ([Al].[Cn] =
[Au].[Cn])) INNER JOIN [Bm] ON ([Bg].[Yr] = [Bm].[Yr]) AND ([Bg].[Cn] =
[Bm].[Cn])) INNER JOIN [Ac] ON [Bm].[Cn] = [Ac].[Cn]) INNER JOIN [Bu] ON
[Ac].[Cn] = [Bu].[Cn]) INNER JOIN Bx ON [Bu].[Cn] = Bx.[Cn]) INNER JOIN Laos
ON Bx.[Cn] = Laos.[Cn]) INNER JOIN [Ca] ON (Laos.[Cn] = [Ca].[Cn]) AND
([Bm].[Yr] = [Ca].[Yr]);


Query5
SELECT [MVA].[Yr], [AA].[Cn],
([MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*(0.95)+[AA]![Dd]-[AA]![Gg])+[AA]![Gg]*[AA]![Hh]+[MCA]![Mm]*[AA]![Ii]-50*([AA]![Cc]-[AA]![Ii]-[AA]![Dd]*(0.95))+[MCA]![Ww]*[AA]![Dd])/1000000
AS [Co], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch],
(([Af]![Ag]*[Af]![Ah]/1000000)+[Ch])/[MVA]![Cx]+[Co] AS [Cp]
FROM [MCA], ([MVA] INNER JOIN [AA] ON [MVA].[Yr]=[AA].[Yr]) INNER JOIN [Af]
ON ([AA].[Yr]=[Af].[Yr]) AND ([AA].[Cn]=[Af].[Cn]);


Query6
SELECT [Query5].[Yr], [Query5].[Cn], [Query5].[Cp], [Query5]![Cp]*[MVA]![Cx]
AS [Cr]
FROM ([Query5] INNER JOIN [MVA] ON [Query5].[Yr] = [MVA].[Yr]) INNER JOIN
[Ao] ON [MVA].[Yr] = [Ao].[Yr];


Query7
SELECT [Query4].[Yr], [Query4].[Cn], [Query4].[Cg], [Query4].[Cf],
[Query4]![Cg]+[Query6]![Cp] AS ConUSD, [Query4]![Cf]+[Query6]![Cr] AS ConTHB,
[Query6].[Cp], [Query6].[Cr]
FROM [Query4], [Query6];


Notes:
- Query4 is so long because I had to rebuild all the formulas from scratch
otherwise I would get “Query too complexâ€
- Query6 should ideally be included in Query5, but I would get a message
saying “Query too complexâ€. It would only work if I put it into a new query.
- I cannot get Query7 to work. The different boards cannot be put into one
query.
- Ideally, the information on Queries 5,6,&7 should all be one query.

I know this is very long, but I couldn’t show you just Query7 without
showing you what precedes it.
Any suggestions?



Klatuu said:
Without seeing the SQL of your queries, we can't even hazard a guess.
 
T

Tara

I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
the end?

Klatuu said:
Sorry, Tara, there is so much there I can't tell by just looking.
--
Dave Hargis, Microsoft Access MVP


Tara said:
Okay...here is an example, but I will have to show you the boards leading up
to the last one as well:

Query1
SELECT [MVA].[Yr], [AA].[Cn], [MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*0.95)/1000000
AS [Ee], [Ee]*[MVA]![Cx] AS [Ff],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd]) AS
[Kk], [Kk]*[MVA]![Cx] AS [Ll],
([MCA]![Mm]*[AA]![Ii]/1000000)-(([AA]![Cc]-[AA]![Ii]-0.95*[AA]![Dd])*50/1000000)
AS [Nn], [Nn]*[MVA]![Cx] AS [Oo], [Ee]+[Kk]+[Nn] AS [Pp], [Pp]*[MVA]![Cx] AS
[Rr]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query2
SELECT [MVA].[Yr], [AA].[Cn], [AA]![Dd]*[MVA]![Bb]/1000000 AS [Ss],
[Ss]*[MVA]![Cx] AS [Tt],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)-([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd])
AS [Uu], [Uu]*[MVA]![Cx] AS [Vv], [MCA]![Ww]*[AA]![Dd]/1000000 AS [Xx],
[Xx]*[MVA]![Cx] AS [Yy], [Ss]+[Uu]+[Xx] AS [Zz], [Zz]*[MVA]![Cx] AS [Ab]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query3
SELECT [MVA].[Yr], [Ac].[Cn], [Ad]/[MVA]![Cx] AS [Ae],
[Af]![Ag]*[Af]![Ah]/1000000 AS [Ad]
FROM [MVA] INNER JOIN ([Ac] INNER JOIN [Af] ON [Ac].[Cn] = [Af].[Cn]) ON
[MVA].[Yr] = [Af].[Yr];


Query4
SELECT [MVA].[Yr], [AK].[Cn],
([Al]![Am]*[MVA]![Bb]/1000000)-([AK]![An]*[Ao]![Ap]/1000000) AS [Ar],
[Ar]*[MVA]![Cx] AS [As],
((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax]))*0.85)*([MVA]![Ay]/1000000)-((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax])/[AK]![Az])*([Ao]![Ba]/1000000))
AS [Bc], [Bc]*[MVA]![Cx] AS [Bd], [Be]/[MVA]![Cx] AS [Bf],
([Bg]![Bh]/([AK]![Bk]/[AK]![Bl]))*(([AK]![Bk]/[AK]![Bl])/0.01)*75*([MVA]![Bb]/1000)/1000000
AS [Be], ([Bm]![Bn]*([MVA]![Bb]/1000000))-([Bm]![Bo]*([Ao]![Ap]/1000000)) AS
[Bp],
([Bp]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*Bx![By]/1000000)
AS [Bz], ([Ca]![Bn]*([MVA]![Bb]/1000000))-([Ca]![Bo]*([Ao]![Ap]/1000000)) AS
[Cb],
([Cb]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*[Ca]![Cd]/1000000)
AS [Ce], [Cf]/[MVA]![Cx] AS [Cg], [As]+[Bd]+[Be]+[Bz]+[Ce] AS [Cf],
[Ch]/[MVA]![Cx] AS [Ck], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch], [Cl]/[MVA]![Cx] AS [Cm],
[Cf]+[Ch] AS [Cl]
FROM [MCA], ((((((([MVA] INNER JOIN (([AK] INNER JOIN [Al] ON [AK].[Cn] =
[Al].[Cn]) INNER JOIN [Ao] ON [Al].[Yr] = [Ao].[Yr]) ON [MVA].[Yr] =
[Al].[Yr]) INNER JOIN ([Au] INNER JOIN [Bg] ON ([Au].[Yr] = [Bg].[Yr]) AND
([Au].[Cn] = [Bg].[Cn])) ON ([Ao].[Yr] = [Au].[Yr]) AND ([Al].[Cn] =
[Au].[Cn])) INNER JOIN [Bm] ON ([Bg].[Yr] = [Bm].[Yr]) AND ([Bg].[Cn] =
[Bm].[Cn])) INNER JOIN [Ac] ON [Bm].[Cn] = [Ac].[Cn]) INNER JOIN [Bu] ON
[Ac].[Cn] = [Bu].[Cn]) INNER JOIN Bx ON [Bu].[Cn] = Bx.[Cn]) INNER JOIN Laos
ON Bx.[Cn] = Laos.[Cn]) INNER JOIN [Ca] ON (Laos.[Cn] = [Ca].[Cn]) AND
([Bm].[Yr] = [Ca].[Yr]);


Query5
SELECT [MVA].[Yr], [AA].[Cn],
([MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*(0.95)+[AA]![Dd]-[AA]![Gg])+[AA]![Gg]*[AA]![Hh]+[MCA]![Mm]*[AA]![Ii]-50*([AA]![Cc]-[AA]![Ii]-[AA]![Dd]*(0.95))+[MCA]![Ww]*[AA]![Dd])/1000000
AS [Co], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch],
(([Af]![Ag]*[Af]![Ah]/1000000)+[Ch])/[MVA]![Cx]+[Co] AS [Cp]
FROM [MCA], ([MVA] INNER JOIN [AA] ON [MVA].[Yr]=[AA].[Yr]) INNER JOIN [Af]
ON ([AA].[Yr]=[Af].[Yr]) AND ([AA].[Cn]=[Af].[Cn]);


Query6
SELECT [Query5].[Yr], [Query5].[Cn], [Query5].[Cp], [Query5]![Cp]*[MVA]![Cx]
AS [Cr]
FROM ([Query5] INNER JOIN [MVA] ON [Query5].[Yr] = [MVA].[Yr]) INNER JOIN
[Ao] ON [MVA].[Yr] = [Ao].[Yr];


Query7
SELECT [Query4].[Yr], [Query4].[Cn], [Query4].[Cg], [Query4].[Cf],
[Query4]![Cg]+[Query6]![Cp] AS ConUSD, [Query4]![Cf]+[Query6]![Cr] AS ConTHB,
[Query6].[Cp], [Query6].[Cr]
FROM [Query4], [Query6];


Notes:
- Query4 is so long because I had to rebuild all the formulas from scratch
otherwise I would get “Query too complexâ€
- Query6 should ideally be included in Query5, but I would get a message
saying “Query too complexâ€. It would only work if I put it into a new query.
- I cannot get Query7 to work. The different boards cannot be put into one
query.
- Ideally, the information on Queries 5,6,&7 should all be one query.

I know this is very long, but I couldn’t show you just Query7 without
showing you what precedes it.
Any suggestions?



Klatuu said:
Without seeing the SQL of your queries, we can't even hazard a guess.
--
Dave Hargis, Microsoft Access MVP


:

words I have seen way too much of today! And if it is not "too compex" then I
get a message saying "insufficient resources".

I have spent the day trying to break up boards into smaller sections and
trying to find other ways to get the same answer. Eventually I have to bring
the seperated boards back together again, so the end result is still the
same: Query is too complex

Does anyone have a suggestion that I could try to get around these
frustrating comments? Should I be using subqueries? - would that help
simplify things in the FROM clause?

Tara
 
K

Klatuu

Sub queries are most often used in the WHERE clause. They can be used in the
FROM, but that would be an less frequent than the WHERE. Which to use
depends on what you want to retrieve. I know that seems a bit vague, but
that is really the ony explanation I can offer.
--
Dave Hargis, Microsoft Access MVP


Tara said:
I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
the end?

Klatuu said:
Sorry, Tara, there is so much there I can't tell by just looking.
--
Dave Hargis, Microsoft Access MVP


Tara said:
Okay...here is an example, but I will have to show you the boards leading up
to the last one as well:

Query1
SELECT [MVA].[Yr], [AA].[Cn], [MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*0.95)/1000000
AS [Ee], [Ee]*[MVA]![Cx] AS [Ff],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd]) AS
[Kk], [Kk]*[MVA]![Cx] AS [Ll],
([MCA]![Mm]*[AA]![Ii]/1000000)-(([AA]![Cc]-[AA]![Ii]-0.95*[AA]![Dd])*50/1000000)
AS [Nn], [Nn]*[MVA]![Cx] AS [Oo], [Ee]+[Kk]+[Nn] AS [Pp], [Pp]*[MVA]![Cx] AS
[Rr]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query2
SELECT [MVA].[Yr], [AA].[Cn], [AA]![Dd]*[MVA]![Bb]/1000000 AS [Ss],
[Ss]*[MVA]![Cx] AS [Tt],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)-([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd])
AS [Uu], [Uu]*[MVA]![Cx] AS [Vv], [MCA]![Ww]*[AA]![Dd]/1000000 AS [Xx],
[Xx]*[MVA]![Cx] AS [Yy], [Ss]+[Uu]+[Xx] AS [Zz], [Zz]*[MVA]![Cx] AS [Ab]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query3
SELECT [MVA].[Yr], [Ac].[Cn], [Ad]/[MVA]![Cx] AS [Ae],
[Af]![Ag]*[Af]![Ah]/1000000 AS [Ad]
FROM [MVA] INNER JOIN ([Ac] INNER JOIN [Af] ON [Ac].[Cn] = [Af].[Cn]) ON
[MVA].[Yr] = [Af].[Yr];


Query4
SELECT [MVA].[Yr], [AK].[Cn],
([Al]![Am]*[MVA]![Bb]/1000000)-([AK]![An]*[Ao]![Ap]/1000000) AS [Ar],
[Ar]*[MVA]![Cx] AS [As],
((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax]))*0.85)*([MVA]![Ay]/1000000)-((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax])/[AK]![Az])*([Ao]![Ba]/1000000))
AS [Bc], [Bc]*[MVA]![Cx] AS [Bd], [Be]/[MVA]![Cx] AS [Bf],
([Bg]![Bh]/([AK]![Bk]/[AK]![Bl]))*(([AK]![Bk]/[AK]![Bl])/0.01)*75*([MVA]![Bb]/1000)/1000000
AS [Be], ([Bm]![Bn]*([MVA]![Bb]/1000000))-([Bm]![Bo]*([Ao]![Ap]/1000000)) AS
[Bp],
([Bp]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*Bx![By]/1000000)
AS [Bz], ([Ca]![Bn]*([MVA]![Bb]/1000000))-([Ca]![Bo]*([Ao]![Ap]/1000000)) AS
[Cb],
([Cb]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*[Ca]![Cd]/1000000)
AS [Ce], [Cf]/[MVA]![Cx] AS [Cg], [As]+[Bd]+[Be]+[Bz]+[Ce] AS [Cf],
[Ch]/[MVA]![Cx] AS [Ck], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch], [Cl]/[MVA]![Cx] AS [Cm],
[Cf]+[Ch] AS [Cl]
FROM [MCA], ((((((([MVA] INNER JOIN (([AK] INNER JOIN [Al] ON [AK].[Cn] =
[Al].[Cn]) INNER JOIN [Ao] ON [Al].[Yr] = [Ao].[Yr]) ON [MVA].[Yr] =
[Al].[Yr]) INNER JOIN ([Au] INNER JOIN [Bg] ON ([Au].[Yr] = [Bg].[Yr]) AND
([Au].[Cn] = [Bg].[Cn])) ON ([Ao].[Yr] = [Au].[Yr]) AND ([Al].[Cn] =
[Au].[Cn])) INNER JOIN [Bm] ON ([Bg].[Yr] = [Bm].[Yr]) AND ([Bg].[Cn] =
[Bm].[Cn])) INNER JOIN [Ac] ON [Bm].[Cn] = [Ac].[Cn]) INNER JOIN [Bu] ON
[Ac].[Cn] = [Bu].[Cn]) INNER JOIN Bx ON [Bu].[Cn] = Bx.[Cn]) INNER JOIN Laos
ON Bx.[Cn] = Laos.[Cn]) INNER JOIN [Ca] ON (Laos.[Cn] = [Ca].[Cn]) AND
([Bm].[Yr] = [Ca].[Yr]);


Query5
SELECT [MVA].[Yr], [AA].[Cn],
([MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*(0.95)+[AA]![Dd]-[AA]![Gg])+[AA]![Gg]*[AA]![Hh]+[MCA]![Mm]*[AA]![Ii]-50*([AA]![Cc]-[AA]![Ii]-[AA]![Dd]*(0.95))+[MCA]![Ww]*[AA]![Dd])/1000000
AS [Co], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch],
(([Af]![Ag]*[Af]![Ah]/1000000)+[Ch])/[MVA]![Cx]+[Co] AS [Cp]
FROM [MCA], ([MVA] INNER JOIN [AA] ON [MVA].[Yr]=[AA].[Yr]) INNER JOIN [Af]
ON ([AA].[Yr]=[Af].[Yr]) AND ([AA].[Cn]=[Af].[Cn]);


Query6
SELECT [Query5].[Yr], [Query5].[Cn], [Query5].[Cp], [Query5]![Cp]*[MVA]![Cx]
AS [Cr]
FROM ([Query5] INNER JOIN [MVA] ON [Query5].[Yr] = [MVA].[Yr]) INNER JOIN
[Ao] ON [MVA].[Yr] = [Ao].[Yr];


Query7
SELECT [Query4].[Yr], [Query4].[Cn], [Query4].[Cg], [Query4].[Cf],
[Query4]![Cg]+[Query6]![Cp] AS ConUSD, [Query4]![Cf]+[Query6]![Cr] AS ConTHB,
[Query6].[Cp], [Query6].[Cr]
FROM [Query4], [Query6];


Notes:
- Query4 is so long because I had to rebuild all the formulas from scratch
otherwise I would get “Query too complexâ€
- Query6 should ideally be included in Query5, but I would get a message
saying “Query too complexâ€. It would only work if I put it into a new query.
- I cannot get Query7 to work. The different boards cannot be put into one
query.
- Ideally, the information on Queries 5,6,&7 should all be one query.

I know this is very long, but I couldn’t show you just Query7 without
showing you what precedes it.
Any suggestions?



:

Without seeing the SQL of your queries, we can't even hazard a guess.
--
Dave Hargis, Microsoft Access MVP


:

words I have seen way too much of today! And if it is not "too compex" then I
get a message saying "insufficient resources".

I have spent the day trying to break up boards into smaller sections and
trying to find other ways to get the same answer. Eventually I have to bring
the seperated boards back together again, so the end result is still the
same: Query is too complex

Does anyone have a suggestion that I could try to get around these
frustrating comments? Should I be using subqueries? - would that help
simplify things in the FROM clause?

Tara
 
J

J_Goddard via AccessMonster.com

One thing you might try is converting some of the queries to make-table
queries to create temporary tables, and then use the tables in the later
queries.

John


Sub queries are most often used in the WHERE clause. They can be used in the
FROM, but that would be an less frequent than the WHERE. Which to use
depends on what you want to retrieve. I know that seems a bit vague, but
that is really the ony explanation I can offer.
I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
[quoted text clipped - 107 lines]
 
K

Klatuu

Some might. I have a personal aversion to make table queries. It could just
as easily be made into a query as I previously suggested.
--
Dave Hargis, Microsoft Access MVP


J_Goddard via AccessMonster.com said:
One thing you might try is converting some of the queries to make-table
queries to create temporary tables, and then use the tables in the later
queries.

John


Sub queries are most often used in the WHERE clause. They can be used in the
FROM, but that would be an less frequent than the WHERE. Which to use
depends on what you want to retrieve. I know that seems a bit vague, but
that is really the ony explanation I can offer.
I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
[quoted text clipped - 107 lines]
 
T

Tara

I'm willing to try just about anything at this point! But how do I convert it
into a table?

J_Goddard via AccessMonster.com said:
One thing you might try is converting some of the queries to make-table
queries to create temporary tables, and then use the tables in the later
queries.

John


Sub queries are most often used in the WHERE clause. They can be used in the
FROM, but that would be an less frequent than the WHERE. Which to use
depends on what you want to retrieve. I know that seems a bit vague, but
that is really the ony explanation I can offer.
I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
[quoted text clipped - 107 lines]
 
T

Tara

Thanks for the explanation. I think I have to play around with both options
some more to really understand how they work.

Klatuu said:
Sub queries are most often used in the WHERE clause. They can be used in the
FROM, but that would be an less frequent than the WHERE. Which to use
depends on what you want to retrieve. I know that seems a bit vague, but
that is really the ony explanation I can offer.
--
Dave Hargis, Microsoft Access MVP


Tara said:
I was afraid you'd say that. But can you answer this? Do subqueries help to
simplify the FROM clause? Why would I use a subquery instead of adding it at
the end?

Klatuu said:
Sorry, Tara, there is so much there I can't tell by just looking.
--
Dave Hargis, Microsoft Access MVP


:

Okay...here is an example, but I will have to show you the boards leading up
to the last one as well:

Query1
SELECT [MVA].[Yr], [AA].[Cn], [MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*0.95)/1000000
AS [Ee], [Ee]*[MVA]![Cx] AS [Ff],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd]) AS
[Kk], [Kk]*[MVA]![Cx] AS [Ll],
([MCA]![Mm]*[AA]![Ii]/1000000)-(([AA]![Cc]-[AA]![Ii]-0.95*[AA]![Dd])*50/1000000)
AS [Nn], [Nn]*[MVA]![Cx] AS [Oo], [Ee]+[Kk]+[Nn] AS [Pp], [Pp]*[MVA]![Cx] AS
[Rr]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query2
SELECT [MVA].[Yr], [AA].[Cn], [AA]![Dd]*[MVA]![Bb]/1000000 AS [Ss],
[Ss]*[MVA]![Cx] AS [Tt],
([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)-([AA]![Gg]*([AA]![Hh]-[MVA]![Bb])/1000000)*[AA]![Ii]/([AA]![Ii]+[AA]![Dd])
AS [Uu], [Uu]*[MVA]![Cx] AS [Vv], [MCA]![Ww]*[AA]![Dd]/1000000 AS [Xx],
[Xx]*[MVA]![Cx] AS [Yy], [Ss]+[Uu]+[Xx] AS [Zz], [Zz]*[MVA]![Cx] AS [Ab]
FROM [MCA], [MVA] INNER JOIN [AA] ON [MVA].[Yr] = [AA].[Yr];


Query3
SELECT [MVA].[Yr], [Ac].[Cn], [Ad]/[MVA]![Cx] AS [Ae],
[Af]![Ag]*[Af]![Ah]/1000000 AS [Ad]
FROM [MVA] INNER JOIN ([Ac] INNER JOIN [Af] ON [Ac].[Cn] = [Af].[Cn]) ON
[MVA].[Yr] = [Af].[Yr];


Query4
SELECT [MVA].[Yr], [AK].[Cn],
([Al]![Am]*[MVA]![Bb]/1000000)-([AK]![An]*[Ao]![Ap]/1000000) AS [Ar],
[Ar]*[MVA]![Cx] AS [As],
((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax]))*0.85)*([MVA]![Ay]/1000000)-((IIf(([AK]![An]*[AK]![At])=0,0,([AK]![An]*[AK]![At])*[Au]![Aw]/[Al]![Ax])/[AK]![Az])*([Ao]![Ba]/1000000))
AS [Bc], [Bc]*[MVA]![Cx] AS [Bd], [Be]/[MVA]![Cx] AS [Bf],
([Bg]![Bh]/([AK]![Bk]/[AK]![Bl]))*(([AK]![Bk]/[AK]![Bl])/0.01)*75*([MVA]![Bb]/1000)/1000000
AS [Be], ([Bm]![Bn]*([MVA]![Bb]/1000000))-([Bm]![Bo]*([Ao]![Ap]/1000000)) AS
[Bp],
([Bp]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*Bx![By]/1000000)
AS [Bz], ([Ca]![Bn]*([MVA]![Bb]/1000000))-([Ca]![Bo]*([Ao]![Ap]/1000000)) AS
[Cb],
([Cb]*[MVA]![Cx])+(((([MVA]![Br]*600)/[Ac]![Bs])+([MVA]![Bt]/[Bu]![Bw]))*[Ca]![Cd]/1000000)
AS [Ce], [Cf]/[MVA]![Cx] AS [Cg], [As]+[Bd]+[Be]+[Bz]+[Ce] AS [Cf],
[Ch]/[MVA]![Cx] AS [Ck], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch], [Cl]/[MVA]![Cx] AS [Cm],
[Cf]+[Ch] AS [Cl]
FROM [MCA], ((((((([MVA] INNER JOIN (([AK] INNER JOIN [Al] ON [AK].[Cn] =
[Al].[Cn]) INNER JOIN [Ao] ON [Al].[Yr] = [Ao].[Yr]) ON [MVA].[Yr] =
[Al].[Yr]) INNER JOIN ([Au] INNER JOIN [Bg] ON ([Au].[Yr] = [Bg].[Yr]) AND
([Au].[Cn] = [Bg].[Cn])) ON ([Ao].[Yr] = [Au].[Yr]) AND ([Al].[Cn] =
[Au].[Cn])) INNER JOIN [Bm] ON ([Bg].[Yr] = [Bm].[Yr]) AND ([Bg].[Cn] =
[Bm].[Cn])) INNER JOIN [Ac] ON [Bm].[Cn] = [Ac].[Cn]) INNER JOIN [Bu] ON
[Ac].[Cn] = [Bu].[Cn]) INNER JOIN Bx ON [Bu].[Cn] = Bx.[Cn]) INNER JOIN Laos
ON Bx.[Cn] = Laos.[Cn]) INNER JOIN [Ca] ON (Laos.[Cn] = [Ca].[Cn]) AND
([Bm].[Yr] = [Ca].[Yr]);


Query5
SELECT [MVA].[Yr], [AA].[Cn],
([MVA]![Bb]*([AA]![Cc]-[AA]![Dd]*(0.95)+[AA]![Dd]-[AA]![Gg])+[AA]![Gg]*[AA]![Hh]+[MCA]![Mm]*[AA]![Ii]-50*([AA]![Cc]-[AA]![Ii]-[AA]![Dd]*(0.95))+[MCA]![Ww]*[AA]![Dd])/1000000
AS [Co], IIf([MVA]![Yr]=2004, 91,(IIf([MVA]![Yr]=2005,
243,(IIf([MVA]![Yr]=2006, 188, (IIf([MVA]![Yr]=2007, 431,
(IIf([MVA]![Yr]>2007,135,0))))))))) AS [Ch],
(([Af]![Ag]*[Af]![Ah]/1000000)+[Ch])/[MVA]![Cx]+[Co] AS [Cp]
FROM [MCA], ([MVA] INNER JOIN [AA] ON [MVA].[Yr]=[AA].[Yr]) INNER JOIN [Af]
ON ([AA].[Yr]=[Af].[Yr]) AND ([AA].[Cn]=[Af].[Cn]);


Query6
SELECT [Query5].[Yr], [Query5].[Cn], [Query5].[Cp], [Query5]![Cp]*[MVA]![Cx]
AS [Cr]
FROM ([Query5] INNER JOIN [MVA] ON [Query5].[Yr] = [MVA].[Yr]) INNER JOIN
[Ao] ON [MVA].[Yr] = [Ao].[Yr];


Query7
SELECT [Query4].[Yr], [Query4].[Cn], [Query4].[Cg], [Query4].[Cf],
[Query4]![Cg]+[Query6]![Cp] AS ConUSD, [Query4]![Cf]+[Query6]![Cr] AS ConTHB,
[Query6].[Cp], [Query6].[Cr]
FROM [Query4], [Query6];


Notes:
- Query4 is so long because I had to rebuild all the formulas from scratch
otherwise I would get “Query too complexâ€
- Query6 should ideally be included in Query5, but I would get a message
saying “Query too complexâ€. It would only work if I put it into a new query.
- I cannot get Query7 to work. The different boards cannot be put into one
query.
- Ideally, the information on Queries 5,6,&7 should all be one query.

I know this is very long, but I couldn’t show you just Query7 without
showing you what precedes it.
Any suggestions?



:

Without seeing the SQL of your queries, we can't even hazard a guess.
--
Dave Hargis, Microsoft Access MVP


:

words I have seen way too much of today! And if it is not "too compex" then I
get a message saying "insufficient resources".

I have spent the day trying to break up boards into smaller sections and
trying to find other ways to get the same answer. Eventually I have to bring
the seperated boards back together again, so the end result is still the
same: Query is too complex

Does anyone have a suggestion that I could try to get around these
frustrating comments? Should I be using subqueries? - would that help
simplify things in the FROM clause?

Tara
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top