在MS Access 中實作ROW_NUMBER / PARTITION BY
在MS Access 中,您可以模擬ROW_NUMBER OVERW_NUMBER OVER (TI BY使用不平等的自連結和聚合。
考慮範例資料:
Ino | TYPE | DOC |
---|---|---|
1 | 1800xxc1 | 3a |
2 | 1810xxc2 | 3b |
3 | 1700xxc3 | 3c |
4 | 1700xxc4 | 3a |
5 | 1800xxc5 | 3a |
6 | 1800xxc6 | 3a |
7 | 1800xxc7 | 3b |
要取得與ROW_NUMBER OVER (PARTITION BY DOC) 類似的結果,請執行下列查詢:
SELECT t1.DOC, t1.TYPE, COUNT(*) AS [Ino Seq] FROM MyData AS t1 INNER JOIN MyData AS t2 ON t2.DOC = t1.DOC AND t2.Ino <= t1.Ino GROUP BY t1.DOC, t1.TYPE ORDER BY 1, 3
以上是如何在 MS Access 中模擬 ROW_NUMBER() OVER (PARTITION BY)?的詳細內容。更多資訊請關注PHP中文網其他相關文章!