Access SQL in Microsoft query in Excel 2010

时间:2016-08-31 12:08:39

标签: sql ms-access excel-2010

I have an MS Access database with several tables that I am trying to reproduce in MS excel using Microsoft Query.
The information from the various tables in access has been copied into seperate sheets in the excel workbook and given the same names as the Access tables.
I have copied the SQL query from access but when I try to use it in access I get the error message

"Could not add the table '('organisations$''

In the query from access to excel I have changed the brackets to ' and put $ at the end for the sheets.
Do you know what I need to do to fix this? Please see the query I am trying to run in excel.

SELECT 
      `Supplier Details$`.Valid To, 
      `Supplier Details$`.Our Customer No AS BU, 
      `Supplier Details$`.Supplier, 
      `Supplier Details$`.Supplier Name, 
      `Supplier Details$`.Due Diligence AS DD, 
      `Supplier Details$`.Insurance Date AS Insurance, 
      `Supplier Details$`.QA Date, 
      `Supplier Details$`.Reference, 
      `All_Active$`.Start_Date, 
      `All_Active$`.H_Process_Status AS Process Status,
      `All_Active$`.H_Outcome_Status, 
      `Supplier Spend$`.Grand Total, 
      `Supplier Spend$`.Number of Months used, 
      `Supplier Spend$`.BU with Max spend, 
      `Status$`.Progress 2
FROM (`Organisation$` INNER JOIN 
     (((`Supplier Details$` LEFT JOIN `All_Active$` 
     ON `Supplier Details$`.Reference = `All_Active$`.H_Vendor_ID) 
     LEFT JOIN `All Waves All BUs$` 
     ON `Supplier Details$`.Reference = `All Waves All BUs$`.Vendor ID
     LEFT JOIN `Supplier Spend$` 
     ON `Supplier Details$`.Supplier = `Supplier Spend$`.Supplier Code MOD) 
     ON `Organisation$`.BU = `Supplier Details$`.Our Customer No) 
     LEFT JOIN `Status$` ON `All_Active$`.H_Process_Status = `Status$`.Status 
GROUP BY `Supplier Details$`.Valid To, 
         `Supplier Details$`.Our Customer No, 
         `Supplier Details$`.Supplier, 
         `Supplier Details$`.Supplier Name, 
         `Supplier Details$`.Due Diligence, 
         `Supplier Details$`.Insurance Date, 
         `Supplier Details$`.QA Date, 
         `Supplier Details$`.Reference, 
         `All_Active$`.Start_Date, 
         `All_Active$`.H_Process_Status, 
         `All_Active$`.H_Outcome_Status, 
         `Supplier Spend$`.Grand Total, 
         `Supplier Spend$`.Number of Months used, 
         `Supplier Spend$`.BU with Max spend, 
         `Status$`.Progress 2, 
         `Supplier Details$`.Address ID, 
         `Supplier Details$`.Expire Date
HAVING (((`Supplier Details$`.Address ID)="1" 
       Or (`Supplier Details$`.Address ID)="01") 
       AND ((`Supplier Details$`.Expire Date) Is Null))
ORDER BY `Supplier Details$`.Valid To

0 个答案:

没有答案
相关问题