C
Conan Kelly
Hello all,
This is killing me. Our table has weekly data in it. I have 2 different versions of underlying queries that will return only the
data that has a weekly date closest to the last day of the month. Then I'm trying to create a crosstab query on each of these
queries. When I run a crosstab on the hokey one, all works fine. When I run the same crosstab query on the more complicated one, I
get the following error message: http://home.att.net/~ctbarbarin/files/crosstab_error_message.jpg
The first, hokey version of the underlying query is (named "qryAL_"):
SELECT [AL(3)].Date, [AL(3)].Market, [AL(3)].Product, [AL(3)].Count, [AL(3)].Average, [AL(3)].High, [AL(3)].Low
FROM [AL(3)]
WHERE (((Day([date]))>24)) OR ((([AL(3)].Date)=#4/24/1998#)) OR ((([AL(3)].Date)=#9/24/1999# Or ([AL(3)].Date)=#2/23/2001# Or
([AL(3)].Date)=#2/22/2002#)) OR ((([AL(3)].Date)=#11/24/2000#)) OR ((([AL(3)].Date)=#7/17/1998#)) OR ((([AL(3)].Date)=#9/24/2004#))
OR ((([AL(3)].Date)=#6/24/2005#)) OR ((([AL(3)].Date)=#12/9/2005#))
ORDER BY [AL(3)].Date;
The second, more complicated version of the underlying query is (NOTE: the table name was changed from AL(3) to AL_3, but the
crosstab error messages were exactly the same (except table name, of course) when run each way):
SELECT AL_3.Date, AL_3.Market, AL_3.Product, AL_3.Count, AL_3.Average, AL_3.High, AL_3.Low
FROM (SELECT MEDate from (SELECT (SELECT MAX([Date]) FROM [AL_3] as MonthEnd WHERE Month([AL_3].Date) = Month([MonthEnd].Date) and
Year([AL_3].Date) = Year([MonthEnd].Date)) AS MEDate FROM AL_3) as Step1 GROUP BY MEdate order by medate) AS Step2 LEFT JOIN AL_3 ON
Step2.MEDate = AL_3.Date
ORDER BY AL_3.Date, AL_3.Product;
These 2 queries will return almost the exact same results, the second one being more accurate than the first w/o having to manually
enter certain dates in the criteria.
The crosstab query I am trying to run on both of these is (adjusting underlying query or table name as necessary):
TRANSFORM Sum(qryAL_.Average) AS SumOfAverage
SELECT qryAL_.Date
FROM qryAL_
GROUP BY qryAL_.Date
PIVOT qryAL_.Product;
When ever I run this on the 1st underlying query, the results are just what I'm looking for. Every time I run it on the 2nd, more
accurate, more complicated, MORE DESIRABLE underlying query, I get the error message, linked to above, immediately. It doesn't
hesitate as if it were trying to execute any of the underlying subqueries.
Is there any way I can get this to work with the 2nd underlying query?
Thanks for any help anyone can provide,
Conan Kelly
This is killing me. Our table has weekly data in it. I have 2 different versions of underlying queries that will return only the
data that has a weekly date closest to the last day of the month. Then I'm trying to create a crosstab query on each of these
queries. When I run a crosstab on the hokey one, all works fine. When I run the same crosstab query on the more complicated one, I
get the following error message: http://home.att.net/~ctbarbarin/files/crosstab_error_message.jpg
The first, hokey version of the underlying query is (named "qryAL_"):
SELECT [AL(3)].Date, [AL(3)].Market, [AL(3)].Product, [AL(3)].Count, [AL(3)].Average, [AL(3)].High, [AL(3)].Low
FROM [AL(3)]
WHERE (((Day([date]))>24)) OR ((([AL(3)].Date)=#4/24/1998#)) OR ((([AL(3)].Date)=#9/24/1999# Or ([AL(3)].Date)=#2/23/2001# Or
([AL(3)].Date)=#2/22/2002#)) OR ((([AL(3)].Date)=#11/24/2000#)) OR ((([AL(3)].Date)=#7/17/1998#)) OR ((([AL(3)].Date)=#9/24/2004#))
OR ((([AL(3)].Date)=#6/24/2005#)) OR ((([AL(3)].Date)=#12/9/2005#))
ORDER BY [AL(3)].Date;
The second, more complicated version of the underlying query is (NOTE: the table name was changed from AL(3) to AL_3, but the
crosstab error messages were exactly the same (except table name, of course) when run each way):
SELECT AL_3.Date, AL_3.Market, AL_3.Product, AL_3.Count, AL_3.Average, AL_3.High, AL_3.Low
FROM (SELECT MEDate from (SELECT (SELECT MAX([Date]) FROM [AL_3] as MonthEnd WHERE Month([AL_3].Date) = Month([MonthEnd].Date) and
Year([AL_3].Date) = Year([MonthEnd].Date)) AS MEDate FROM AL_3) as Step1 GROUP BY MEdate order by medate) AS Step2 LEFT JOIN AL_3 ON
Step2.MEDate = AL_3.Date
ORDER BY AL_3.Date, AL_3.Product;
These 2 queries will return almost the exact same results, the second one being more accurate than the first w/o having to manually
enter certain dates in the criteria.
The crosstab query I am trying to run on both of these is (adjusting underlying query or table name as necessary):
TRANSFORM Sum(qryAL_.Average) AS SumOfAverage
SELECT qryAL_.Date
FROM qryAL_
GROUP BY qryAL_.Date
PIVOT qryAL_.Product;
When ever I run this on the 1st underlying query, the results are just what I'm looking for. Every time I run it on the 2nd, more
accurate, more complicated, MORE DESIRABLE underlying query, I get the error message, linked to above, immediately. It doesn't
hesitate as if it were trying to execute any of the underlying subqueries.
Is there any way I can get this to work with the 2nd underlying query?
Thanks for any help anyone can provide,
Conan Kelly