P
PatT123
I am having problems formatting a SQL Statement with Multiple joined Queries.
The query works in three pieces as named queries, but I want to pull it into
one query to put behind a form. Please help me find code that will help me
with the structure.
Syntax Error in From Clause, but will save….
SELECT POSUpdt.PosNo, POSUpdt.Funding, POSUpdt.PCA, POSUpdt.Fund,
POSUpdt.FedGrant_PH, POSUpdt.OthGrant_PH, POSUpdt.Percent,
POSUpdt.SubProgram, POSUpdt.DIVFund, FTEUpdt.SumOfPercent, FTEUpdt.DIVFund
FROM [SELECT TBLFUNDINGTOPOS.PosNo, TBLFUNDING.Funding, TBLFUNDING.PCA,
TBLPCA.Fund, TBLFUNDING.FedGrant_PH, TBLFUNDING.OthGrant_PH,
TBLFUNDINGTOPOS.Percent, TBLPCA.SubProgram, TBLIndex!DIV & TBLPCA!Fund AS
DIVFund
FROM (TBLIndex RIGHT JOIN TBLPosition ON TBLIndex.Index = TBLPosition.Index)
RIGHT JOIN ((TBLFunds RIGHT JOIN TBLPCA ON TBLFunds.FUND = TBLPCA.Fund) RIGHT
JOIN (TBLFUNDING RIGHT JOIN TBLFUNDINGTOPOS ON TBLFUNDING.Funding =
TBLFUNDINGTOPOS.Funding) ON TBLPCA.PCA = TBLFUNDING.PCA) ON TBLPosition.PosNo
= TBLFUNDINGTOPOS.PosNo]. AS POSUpdt LEFT JOIN [SELECT TBLFTETotals.FTETotal,
QRY1.SumOfPercent, TBLFTETotals.DIVFund
FROM TBLFTETotals LEFT JOIN (SELECT Sum(TBLFundingToPos1.Percent) AS
SumOfPercent, TBLIndex1.DIV & TBLPCA1.Fund AS DIVFUND
FROM (TBLIndex1 RIGHT JOIN TBLPosition1 ON TBLIndex1.Index =
TBLPosition1.Index) RIGHT JOIN ((TBLFunding1 LEFT JOIN TBLPCA1 ON
TBLFunding1.PCA = TBLPCA1.PCA) RIGHT JOIN TBLFundingToPos1 ON
TBLFunding1.Funding = TBLFundingToPos1.Funding) ON TBLPosition1.PosNo =
TBLFundingToPos1.PosNo
GROUP BY TBLIndex1.DIV, TBLPCA1.Fund). AS QRY1 ON TBLFTETotals.DIVFund =
QRY1.DIVFUND]. AS FTEUpdt ON POSUpdt.DIVFund = FTEUpdt.DIVFund;
Queries as Named in the Database. It does run. Cannot replace names with
Code.
SELECT Query3.PosNo, Query3.Funding, Query3.PCA, Query3.Fund,
Query3.FedGrant_PH, Query3.OthGrant_PH, Query3.Percent, Query3.SubProgram,
Query3.DIVFund, Query2.SumOfPercent, Query2.DIVFund
FROM Query3 LEFT JOIN Query2 ON Query3.DIVFund = Query2.DIVFund;
Thank You
Pat
The query works in three pieces as named queries, but I want to pull it into
one query to put behind a form. Please help me find code that will help me
with the structure.
Syntax Error in From Clause, but will save….
SELECT POSUpdt.PosNo, POSUpdt.Funding, POSUpdt.PCA, POSUpdt.Fund,
POSUpdt.FedGrant_PH, POSUpdt.OthGrant_PH, POSUpdt.Percent,
POSUpdt.SubProgram, POSUpdt.DIVFund, FTEUpdt.SumOfPercent, FTEUpdt.DIVFund
FROM [SELECT TBLFUNDINGTOPOS.PosNo, TBLFUNDING.Funding, TBLFUNDING.PCA,
TBLPCA.Fund, TBLFUNDING.FedGrant_PH, TBLFUNDING.OthGrant_PH,
TBLFUNDINGTOPOS.Percent, TBLPCA.SubProgram, TBLIndex!DIV & TBLPCA!Fund AS
DIVFund
FROM (TBLIndex RIGHT JOIN TBLPosition ON TBLIndex.Index = TBLPosition.Index)
RIGHT JOIN ((TBLFunds RIGHT JOIN TBLPCA ON TBLFunds.FUND = TBLPCA.Fund) RIGHT
JOIN (TBLFUNDING RIGHT JOIN TBLFUNDINGTOPOS ON TBLFUNDING.Funding =
TBLFUNDINGTOPOS.Funding) ON TBLPCA.PCA = TBLFUNDING.PCA) ON TBLPosition.PosNo
= TBLFUNDINGTOPOS.PosNo]. AS POSUpdt LEFT JOIN [SELECT TBLFTETotals.FTETotal,
QRY1.SumOfPercent, TBLFTETotals.DIVFund
FROM TBLFTETotals LEFT JOIN (SELECT Sum(TBLFundingToPos1.Percent) AS
SumOfPercent, TBLIndex1.DIV & TBLPCA1.Fund AS DIVFUND
FROM (TBLIndex1 RIGHT JOIN TBLPosition1 ON TBLIndex1.Index =
TBLPosition1.Index) RIGHT JOIN ((TBLFunding1 LEFT JOIN TBLPCA1 ON
TBLFunding1.PCA = TBLPCA1.PCA) RIGHT JOIN TBLFundingToPos1 ON
TBLFunding1.Funding = TBLFundingToPos1.Funding) ON TBLPosition1.PosNo =
TBLFundingToPos1.PosNo
GROUP BY TBLIndex1.DIV, TBLPCA1.Fund). AS QRY1 ON TBLFTETotals.DIVFund =
QRY1.DIVFUND]. AS FTEUpdt ON POSUpdt.DIVFund = FTEUpdt.DIVFund;
Queries as Named in the Database. It does run. Cannot replace names with
Code.
SELECT Query3.PosNo, Query3.Funding, Query3.PCA, Query3.Fund,
Query3.FedGrant_PH, Query3.OthGrant_PH, Query3.Percent, Query3.SubProgram,
Query3.DIVFund, Query2.SumOfPercent, Query2.DIVFund
FROM Query3 LEFT JOIN Query2 ON Query3.DIVFund = Query2.DIVFund;
Thank You
Pat