Nice to know that it was something simple. First of all an alias can save
space. For example here's your original SQL fixed up some:
SELECT A.[Long Style],
A.[On Hand],
A.[On Order]
FROM [Weekly Demand] AS A
INNER JOIN (select [long style],
max([week end date]) as [max date]
from [weekly demand] group by [long style]) AS B
ON (A.[Long Style] = B.[long style])
AND (A.[Week End Date] = B.[max date]);
Now let's get rid of the A alias and plug in the actual table name:
SELECT [WEEKLY DEMAND].[Long Style],
[WEEKLY DEMAND].[On Hand],
[WEEKLY DEMAND].[On Order]
FROM [Weekly Demand]
INNER JOIN (select [long style],
max([week end date]) as [max date]
from [weekly demand] group by [long style]) AS B
ON ([WEEKLY DEMAND].[Long Style] = B.[long style])
AND ([WEEKLY DEMAND].[Week End Date] = B.[max date]);
Notice that it's a little longer. Now imagine that instead of the table
being named [WEEKLY DEMAND] someone when nutzo and called it something like:
[WEEKLY DEMAND OF PARTS AND MATERIALS].
Remember that a field or table name can be up to 64 characters. That could
get ugly!
Now look at your B alias. It's actually an alias for a subquery. I've never
done one without an alias so I don't know if it would even work with
something like:
([select [long style],max([week end date]) as [max date] from [weekly
demand] group by [long style]]).[long style]
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
patti said:
well - lookie there. Thanks!
Here's the sql:
SELECT A.[Long Style], A.[On Hand], A.[On Order]
FROM [Weekly Demand] AS A INNER JOIN [select [long style],max([week end
date]) as [max date] from [weekly demand] group by [long style]]. AS B ON
(A.[Long Style] = B.[long style]) AND (A.[Week End Date] = B.[max date]);
aliases are alien to me. if you would be so kind, could u provide me a short
explanation of what/why.
thanks.
Jerry Whittle said:
Could be a few things. For example A and B are queries and not tables.
Whoops! You already eliminated that. Make sure to scroll left and right on
the database window if there are scroll bars. They could just be out of site.
They could be aliases where a table is temporarily named A or B.
Someone could have hidden the tables. If soon the menu go to Tools, Options,
the select the View tab. Put a checkmark in Hidden Objects and System Objects
to see if they then show up.
Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here. Maybe that will give up a secret or two!