Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting T-SQL Left Join Subqueries to MS-Access
    primarykey
    data
    text
    <p>I need help in converting this T-SQL query to MS ACCESS. The error that I'm getting is JOIN expression not supported.</p> <p>Update:</p> <p>I can't add:</p> <p>DDA ON TT.[Description] = DDA.AccountTypeDesc AND H.AccountNumber = DDA.AccountNumber</p> <p>But</p> <p>DDA ON TT.[Description] = DDA.AccountTypeDesc</p> <p>works. Is there a way to add the second condition?</p> <p>T-SQL Query:</p> <pre><code>SELECT * FROM ( SELECT [PesoAmount] = CASE WHEN FE.IsoCode IS NULL THEN LTRIM(STR(DFCF.CurrencyAmount, 20, 2)) ELSE LTRIM(STR(DFCF.CurrencyAmount * FE.PhpConversionRate, 20, 2)) END, DFCF.TransactionNumber, DFCF.AccountNumber, DFCF.CountryCd, DFCF.TransactionTypeCd, DFCF.Time, DFCF.Date, DFCF.TransactionStatusCd, DFCF.TransactionCurrencyCd, DFCF.BranchNumber, DFCF.RemitterExtPartyCd, DFCF.BeneficiaryExtPartyCd, DFCF.PostedDate, DFCF.AssociateNumber, DFCF.ExecutingPartyNumber, DFCF.CurrencyAmount, DFCF.CurrencyAmountInTxnCcy, DFCF.CurrencyAmountInAccountCcy, DFCF.SecondaryAccountKey, DFCF.RelatedInd, DFCF.ThirdPartyInd, DFCF.TransactionDescription, DFCF.SecurityName, DFCF.DealNumber FROM dbo.DesFactCashFlow DFCF (NOLOCK) LEFT JOIN dbo.ForeignExchange FE (NOLOCK) ON DFCF.TransactionCurrencyCd = FE.IsoCode ) H LEFT JOIN dbo.Ctr C (NOLOCK) ON H.PesoAmount = C.PesoAmountFaceValueSumInsured AND H.AccountNumber = C.AccountNumber AND H.TransactionTypeCd = C.TransactionType LEFT JOIN dbo.TransactionType TT (NOLOCK) ON H.TransactionTypeCd = TT.Code LEFT JOIN ( SELECT [AccountNumber] = DDA2.AccountNumber, [AccountTypeDesc] = DDA2.AccountTypeDesc, [LineOfBusinessName] = MAX(DDA2.LineOfBusinessName), [AccountCurrencyCode] = MAX(DDA2.AccountCurrencyCode), [AccountCurrencyName] = MAX(DDA2.AccountCurrencyName), [AccountRegistrationTypeDesc] = MAX(DDA2.AccountRegistrationTypeDesc), [AccountRegistrationName] = MAX(DDA2.AccountRegistrationName), [AccountName] = MAX(DDA2.AccountName), [AlternateName] = MAX(DDA2.AlternateName), [AccountOpenDate] = MAX(DDA2.AccountOpenDate), [AccountCloseDate] = MAX(DDA2.AccountCloseDate), [AccountStatusDesc] = MAX(DDA2.AccountStatusDesc), [DormantInd] = MAX(DDA2.DormantInd), [ProductLineName] = MAX(DDA2.ProductLineName), [ProductCategoryName] = MAX(DDA2.ProductCategoryName), [ProductTypeName] = MAX(DDA2.ProductTypeName), [ProductName] = MAX(DDA2.ProductName), [ProductNumber] = MAX(DDA2.ProductNumber), [AccountTaxId] = MAX(DDA2.AccountTaxId), [AccountTaxIdTypeCode] = MAX(DDA2.AccountTaxIdTypeCode), [AccountTaxStateCode] = MAX(DDA2.AccountTaxStateCode), [AccountPrimaryBranchName] = MAX(DDA2.AccountPrimaryBranchName), [MailingAddress1] = MAX(DDA2.MailingAddress1), [MailingAddress2] = MAX(DDA2.MailingAddress2), [MailingCityName] = MAX(DDA2.MailingCityName), [MailingStateCode] = MAX(DDA2.MailingStateCode), [MailingStateName] = MAX(DDA2.MailingStateName), [MailingPostalCode] = MAX(DDA2.MailingPostalCode), [MailingCountryCode] = MAX(DDA2.MailingCountryCode), [MailingCountryName] = MAX(DDA2.MailingCountryName), [CurrencyBasedAccountInd] = MAX(DDA2.CurrencyBasedAccountInd), [MaturityDate] = MAX(DDA2.MaturityDate), [OriginalLoanAmount] = MAX(DDA2.OriginalLoanAmount), [CollateralTypeDesc] = MAX(DDA2.CollateralTypeDesc), [CollateralTypeCode] = MAX(DDA2.CollateralTypeCode), [InsuredAmount] = MAX(DDA2.InsuredAmount), [EmployeeInd] = MAX(DDA2.EmployeeInd) FROM dbo.DesDimAccount DDA2 (NOLOCK) GROUP BY DDA2.AccountNumber, DDA2.AccountTypeDesc ) DDA ON RTRIM(TT.[Description]) = RTRIM(DDA.AccountTypeDesc) AND H.AccountNumber = DDA.AccountNumber </code></pre> <p>EDIT: I replaced the query with the AS keyword. I get the same error. MS Access Query with Error:</p> <pre><code>SELECT 'H' AS [HeaderRecordIndicator], '1' AS [SupervisingAgency], '0' + I.InstitutionCode AS [InstitutionCode], CONVERT(char(8), H.Date, 112) AS [ReportDate], 'CTR' AS [ReportType], '21' AS [FormatCode], '1' AS [SubmissionType] FROM ((( SELECT IIF(ISNULL(FE.IsoCode), FORMAT(DFCF.CurrencyAmount, "##################.00"), FORMAT(DFCF.CurrencyAmount * FE.PhpConversionRate, "##################.00")) AS [PesoAmount], DFCF.TransactionNumber, DFCF.AccountNumber, DFCF.CountryCd, DFCF.TransactionTypeCd, DFCF.Time, DFCF.Date, DFCF.TransactionStatusCd, DFCF.TransactionCurrencyCd, DFCF.BranchNumber, DFCF.RemitterExtPartyCd, DFCF.BeneficiaryExtPartyCd, DFCF.PostedDate, DFCF.AssociateNumber, DFCF.ExecutingPartyNumber, DFCF.CurrencyAmount, DFCF.CurrencyAmountInTxnCcy, DFCF.CurrencyAmountInAccountCcy, DFCF.SecondaryAccountKey, DFCF.RelatedInd, DFCF.ThirdPartyInd, DFCF.TransactionDescription, DFCF.SecurityName, DFCF.DealNumber FROM DesFactCashFlow DFCF LEFT JOIN ForeignExchange FE ON DFCF.TransactionCurrencyCd = FE.IsoCode ) AS H LEFT JOIN Ctr C ON H.PesoAmount = C.PesoAmountFaceValueSumInsured AND H.AccountNumber = C.AccountNumber AND H.TransactionTypeCd = C.TransactionType) LEFT JOIN TransactionType TT ON H.TransactionTypeCd = TT.Code) LEFT JOIN ( SELECT DDA2.AccountNumber AS [AccountNumber], DDA2.AccountTypeDesc AS [AccountTypeDesc], MAX(DDA2.LineOfBusinessName) AS [LineOfBusinessName], MAX(DDA2.AccountCurrencyCode) AS [AccountCurrencyCode], MAX(DDA2.AccountCurrencyName) AS [AccountCurrencyName], MAX(DDA2.AccountRegistrationTypeDesc) AS [AccountRegistrationTypeDesc], MAX(DDA2.AccountRegistrationName) AS [AccountRegistrationName], MAX(DDA2.AccountName) AS [AccountName], MAX(DDA2.AlternateName) AS [AlternateName], MAX(DDA2.AccountOpenDate) AS [AccountOpenDate], MAX(DDA2.AccountCloseDate) AS [AccountCloseDate], MAX(DDA2.AccountStatusDesc) AS [AccountStatusDesc], MAX(DDA2.DormantInd) AS [DormantInd], MAX(DDA2.ProductLineName) AS [ProductLineName], MAX(DDA2.ProductCategoryName) AS [ProductCategoryName], MAX(DDA2.ProductTypeName) AS [ProductTypeName], MAX(DDA2.ProductName) AS [ProductName], MAX(DDA2.ProductNumber) AS [ProductNumber], MAX(DDA2.AccountTaxId) AS [AccountTaxId], MAX(DDA2.AccountTaxIdTypeCode) AS [AccountTaxIdTypeCode], MAX(DDA2.AccountTaxStateCode) AS [AccountTaxStateCode], MAX(DDA2.AccountPrimaryBranchName) AS [AccountPrimaryBranchName], MAX(DDA2.MailingAddress1) AS [MailingAddress1], MAX(DDA2.MailingAddress2) AS [MailingAddress2], MAX(DDA2.MailingCityName) AS [MailingCityName], MAX(DDA2.MailingStateCode) AS [MailingStateCode], MAX(DDA2.MailingStateName) AS [MailingStateName], MAX(DDA2.MailingPostalCode) AS [MailingPostalCode], MAX(DDA2.MailingCountryCode) AS [MailingCountryCode], MAX(DDA2.MailingCountryName) AS [MailingCountryName], MAX(DDA2.CurrencyBasedAccountInd) AS [CurrencyBasedAccountInd], MAX(DDA2.MaturityDate) AS [MaturityDate], MAX(DDA2.OriginalLoanAmount) AS [OriginalLoanAmount], MAX(DDA2.CollateralTypeDesc) AS [CollateralTypeDesc], MAX(DDA2.CollateralTypeCode) AS [CollateralTypeCode], MAX(DDA2.InsuredAmount) AS [InsuredAmount], MAX(DDA2.EmployeeInd) AS [EmployeeInd] FROM DesDimAccount DDA2 GROUP BY DDA2.AccountNumber, DDA2.AccountTypeDesc ) AS DDA ON RTRIM(TT.[Description]) = RTRIM(DDA.AccountTypeDesc) AND H.AccountNumber = DDA.AccountNumber </code></pre> <p>Here is the simplified query with the same error:</p> <pre><code>SELECT * FROM ((( SELECT IIF(ISNULL(FE.IsoCode), FORMAT(DFCF.CurrencyAmount, "##################.00"), FORMAT(DFCF.CurrencyAmount * FE.PhpConversionRate, "##################.00")) AS [PesoAmount], DFCF.TransactionNumber, DFCF.TransactionCurrencyCd, FROM DesFactCashFlow DFCF LEFT JOIN ForeignExchange FE ON DFCF.TransactionCurrencyCd = FE.IsoCode ) AS H LEFT JOIN Ctr C ON H.PesoAmount = C.PesoAmountFaceValueSumInsured AND H.AccountNumber = C.AccountNumber AND H.TransactionTypeCd = C.TransactionType) LEFT JOIN TransactionType TT ON H.TransactionTypeCd = TT.Code) LEFT JOIN ( SELECT DDA2.AccountNumber AS [AccountNumber], DDA2.AccountTypeDesc AS [AccountTypeDesc], MAX(DDA2.LineOfBusinessName) AS [LineOfBusinessName], FROM DesDimAccount DDA2 GROUP BY DDA2.AccountNumber, DDA2.AccountTypeDesc ) AS DDA ON RTRIM(TT.[Description]) = RTRIM(DDA.AccountTypeDesc) AND H.AccountNumber = DDA.AccountNumber </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload