upobDaPlaya
asked on
Multiple FROM Clauses in VBA code for a single block of code
Why are three FROM clauses needed below..I assume the second FROM clause is needed to build the first ? If that is the case does the order of the FROM clause matter ?
Note the below works..I am just trying to understand it....
Select G.Client, G.Date
FROM(Select GROCERY.Client,GROCERY.DAT E
FROM (Select LEFT([FullClientName,40) AS Client,Date
FROM strExcelWSName
WHERE [Product] = 'Pizza') AS GROCERY
INNER JOIN (Select LEFT([FullClientName,40) AS Client,Date
FROM strWSName
WHERE [Product] = 'Soybeans' AS AG
ON GROCERY.CLIENT = AG.CLIENT
GROUP BY GROCERY.CLIENT,GROCERY.DAT E AS
Note the below works..I am just trying to understand it....
Select G.Client, G.Date
FROM(Select GROCERY.Client,GROCERY.DAT
FROM (Select LEFT([FullClientName,40) AS Client,Date
FROM strExcelWSName
WHERE [Product] = 'Pizza') AS GROCERY
INNER JOIN (Select LEFT([FullClientName,40) AS Client,Date
FROM strWSName
WHERE [Product] = 'Soybeans' AS AG
ON GROCERY.CLIENT = AG.CLIENT
GROUP BY GROCERY.CLIENT,GROCERY.DAT
That code would not work "as is", there are syntax errors
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OMG ! The indentation makes a huge difference. So the hierarchy of the sub-queries then is the one that always appears at the top is the one that gets built last..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all...makes sense