我有以下的MS Access查詢,成功地檢索數據:女士訪問獲得行號從子查詢不表
SELECT stockInventory.purchaseId, stockInventory.itemId, item.itemName, stockInventory.unitId, unit.unitDesc, stockInventory.quantity, stockInventory.costPrice
FROM unit INNER JOIN (item INNER JOIN stockInventory ON item.itemId = stockInventory.itemId) ON unit.unitId = stockInventory.unitId
WHERE (((stockInventory.purchaseId)=1))
現在我想找回這些數據與行號!
我試過如下:
SELECT A.*, (SELECT COUNT(*) FROM A WHERE A.itemId>=itemId) as rowNo
FROM
(
SELECT stockInventory.purchaseId, stockInventory.itemId, item.itemName, stockInventory.unitId, unit.unitDesc, stockInventory.quantity, stockInventory.costPrice
FROM unit INNER JOIN (item INNER JOIN stockInventory ON item.itemId = stockInventory.itemId) ON unit.unitId = stockInventory.unitId
WHERE (((stockInventory.purchaseId)=1))
) AS A;
但它說:Microsoft Access數據庫引擎無法找到輸入表或查詢 'A',如下圖:
如何我可以解決這個問題嗎?
你能提供的查詢不計數呢?然後,更容易理解你想要達到的目標。 –
這個查詢得到總記錄:SELECT COUNT(*)FROM SELECT stockInventory.purchaseId,stockInventory.itemId,item.itemName,stockInventory.unitId,unit.unitDesc,stockInventory.quantity,stockInventory.costPrice FROM單元INNER ( JOIN(item INNER JOIN stockInventory ON item.itemId = stockInventory.itemId)ON unit.unitId = stockInventory.unitId WHERE(((stockInventory.purchaseId)= 1)) )AS A; –