0

次のステートメントで行 100 を行 200 に抽出するにはどうすればよいですか。

SELECT Offices.OfficeID, ContractsBooksCommodities.CommodityID
  FROM ((((Offices 
    INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID) 
    INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)      
    INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum) 
    INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum) 
    INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum;
4

1 に答える 1

0

これは遅いかもしれません:

SELECT Top 101 Offices.OfficeID, ContractsBooksCommodities.CommodityID
  FROM ((((Offices 
    INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID) 
    INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)      
    INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum) 
    INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum) 
    INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum
WHERE Offices.OfficeID NOT IN (SELECT Top 99 Offices.OfficeID
  FROM ((((Offices 
    INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID) 
    INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)      
    INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum) 
    INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum) 
    INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum
ORDER BY Offices.OfficeID, ContractsBooksCommodities.CommodityID) 
ORDER BY Offices.OfficeID, ContractsBooksCommodities.CommodityID

どのフィールドがソートを一意にするかはわかりませんが、MS Accessはそれ以外の場合は一致を返すため、これが必要です。

于 2013-02-15T00:12:05.273 に答える