Could not add the table (

后端 未结 1 1327
抹茶落季
抹茶落季 2021-01-25 07:15

The following code works in Sage200.

SELECT bcs.BomReference
    ,bcs.DateTimeCosted
    ,bcs.TotalCost
FROM (
    SELECT BomReference
        ,Max(DateTimeCos         


        
相关标签:
1条回答
  • 2021-01-25 07:30

    The issue with MSQuery is that it attempts to display your query graphically in it's design view, this works OK for simple queries but not for complex queries which usually generates the could not add table message. The way I found around this is to treat your query as one big sub query inside a wrapper query, this forces MSQuery to give up the design view and work as pure SQL text.

    Another issue might be that for one table you have the full path but not the others, is it correct for the table you have included it and does it need to be used on the other tables.

    Here is an example of the changes I think you should make:

    SELECT * FROM (
    SELECT bcs.BomReference
      ,bcs.DateTimeCosted
      ,bcs.TotalCost
      ,BomBuildProduct.StockDescription
    FROM 
      (SELECT BomReference
         ,Max(DateTimeCosted) AS MaxDate
       FROM NDM_Sage200.dbo.BomCostSession BomCostSession
       GROUP BY BomReference) AS ldc
    INNER JOIN NDM_Sage200.dbo.BomCostSession AS bcs ON bcs.BomReference = ldc.BomReference
      AND bcs.DateTimeCosted = ldc.MaxDate
    INNER JOIN NDM_Sage200.dbo.BomBuildPackage ON BomCostSession.BomBuildPackageID = BomBuildPackage.BomBuildPackageID
    INNER JOIN NDM_Sage200.dbo.BomBuildProduct ON BomBuildPackage.BomRecordID = BomBuildProduct.BomRecordID) x
    ORDER BY BomReference
    
    0 讨论(0)
提交回复
热议问题