使用 Microsoft Access 查询结果中的行号 [英] Row numbers in query result using Microsoft Access
本文介绍了使用 Microsoft Access 查询结果中的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我总是在 sql server 中使用这个查询来获取表中的行号:
I always use this query in sql server to get Row number in a table:
SELECT *
FROM (SELECT *,
Row_number()
OVER(
ORDER BY [myidentitycolumn]) RowID
FROM mytable) sub
WHERE rowid = 15
现在我在 Access 2010 中工作,但这似乎不起作用.Access 中是否有此查询的替代品?
Now I am working in Access 2010 and this seems to be not working. Is there any replacement for this query in Access?
推荐答案
MS-Access 不支持 ROW_NUMBER().使用 TOP 1:
MS-Access doesn't support ROW_NUMBER(). Use TOP 1:
SELECT TOP 1 *
FROM [MyTable]
ORDER BY [MyIdentityCOlumn]
如果您需要第 15 行 - MS-Access 没有简单的内置方法来执行此操作.您可以通过使用反向嵌套排序来模拟行号来获得:
If you need the 15th row - MS-Access has no simple, built-in, way to do this. You can simulate the rownumber by using reverse nested ordering to get this:
SELECT TOP 1 *
FROM (
SELECT TOP 15 *
FROM [MyTable]
ORDER BY [MyIdentityColumn] ) t
ORDER BY [MyIdentityColumn] DESC
这篇关于使用 Microsoft Access 查询结果中的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文