-2

データセットに対して次のクエリを実行しようとしています:

SELECT 
  S.CUSIP, S.SecName, 
  ISNULL(RA.FinInstCode, '') AS RemarketingAgent, 
  S.IssueDate, S.MaturityDate, F2.FinInstName AS Trustee, 
  CASE WHEN SC1.ExpirationDate IS NULL 
    THEN '' ELSE ISNULL(F1.FinInstCode, '') END 
  AS CreditProvider, 
  CASE WHEN SC1.ExpirationDate IS NULL 
    THEN '' ELSE ISNULL(C1.CreditEnhancementCode, '') END 
  AS CreditType, 
  SC1.ExpirationDate AS CreditExpirationDate, 
  SC1.RefNum AS RefNumber
FROM
  dbo.SecurityCreditEnhancementProvider SC1, 
  dbo.FinInst F1, 
  dbo.LUCreditEnhancement C1, 
  { oj { oj dbo.Security S 
LEFT OUTER JOIN
  dbo.FinInst F2 ON S.TrusteeID = F2.FinInstID } 
LEFT OUTER JOIN
  dbo.FinInst RA ON S.RemarketingAgentID = RA.FinInstID }
WHERE
  S.SecID = SC1.SecID 
AND 
  SC1.CreditProviderID = F1.FinInstID 
AND 
  SC1.CreditEnhancementID = C1.CreditEnhancementID 
AND 
  C1.CreditEnhancementCode = 'LOC' OR
  C1.CreditEnhancementCode = 'LIQUIDITY' 
AND 
  (S.ActiveFlag = 'A') 
AND 
  (S.SecTypeID NOT IN (4, 7))
ORDER BY CreditExpirationDate

クエリを実行しようとすると、「Error in FROM clause near: '{' . Unable to parse query.」というエラーが表示されます。

この問題を解決するための助けをいただければ幸いです。

ありがとう、

編集 1:これは、クエリ デザイナーがコードを変更した後の外観です。

FROM         { oj { oj { oj { oj { oj dbo.SecurityCreditEnhancementProvider SC1 LEFT OUTER JOIN
                  dbo.FinInst F1 ON SC1.CreditProviderID = F1.FinInstID } LEFT OUTER JOIN
                  dbo.LUCreditEnhancement C1 ON SC1.CreditEnhancementID = C1.CreditEnhancementID } LEFT OUTER JOIN
                  dbo.Security S ON S.SecID = SC1.SecID } LEFT OUTER JOIN
                  dbo.FinInst F2 ON S.TrusteeID = F2.FinInstID } LEFT OUTER JOIN
                  dbo.FinInst RA ON S.RemarketingAgentID = RA.FinInstID }

助けてくれてありがとう。

4

1 に答える 1

0

このような場合にコードをフォーマットすると役立つ場合があります。FROM句の構文が正しくありませんでした。また、テーブル間にコンマを使用する代わりに、すべてのテーブルで JOIN 構文を使用するようにクエリを更新しました。

SELECT S.CUSIP
    , S.SecName
    , ISNULL(RA.FinInstCode, '') AS RemarketingAgent
    , S.IssueDate
    , S.MaturityDate
    , F2.FinInstName AS Trustee
    , CASE WHEN SC1.ExpirationDate IS NULL THEN '' ELSE ISNULL(F1.FinInstCode, '') END AS CreditProvider
    , CASE WHEN SC1.ExpirationDate IS NULL THEN '' ELSE ISNULL(C1.CreditEnhancementCode, '') END AS CreditType
    , SC1.ExpirationDate AS CreditExpirationDate
    , SC1.RefNum AS RefNumber
FROM dbo.SecurityCreditEnhancementProvider SC1
LEFT JOIN dbo.FinInst F1
    ON SC1.CreditProviderID = F1.FinInstID 
LEFT JOIN dbo.LUCreditEnhancement C1
    ON SC1.CreditEnhancementID = C1.CreditEnhancementID 
LEFT JOIN dbo.Security S 
    ON S.SecID = SC1.SecID 
LEFT OUTER JOIN dbo.FinInst F2 
    ON S.TrusteeID = F2.FinInstID
LEFT OUTER JOIN dbo.FinInst RA 
    ON S.RemarketingAgentID = RA.FinInstID
WHERE (C1.CreditEnhancementCode = 'LOC' OR C1.CreditEnhancementCode = 'LIQUIDITY' )
    AND (S.ActiveFlag = 'A') 
    AND (S.SecTypeID NOT IN (4, 7))
ORDER BY CreditExpirationDate
于 2012-05-30T22:24:35.380 に答える