Link to home
Start Free TrialLog in
Avatar of upobDaPlaya
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.DATE
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.DATE AS
Avatar of PortletPaul
PortletPaul
Flag of Australia image

That code would not work "as is", there are syntax errors
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of upobDaPlaya
upobDaPlaya

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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks all...makes sense