2我有一个包含两个字段的查询(无论如何,为了这个例子的目的): -
RecordID
RecordDate
此表按RecordDate(升序)排序。
我想找出RecordID中指定值的查询中的位置。
因此,例如,如果我的表包含以下内容: -
10 15/2/1989
11 15/3/1989
12 15/4/1989
13 15/5/1989
我的价值是'11',然后我想要返回第2行...这是可能的吗?
答案 0 :(得分:1)
SELECT
ROW_NUMBER() OVER (ORDER BY RecordDate) AS Row,
RecordID, RecordDate
from
YourTablename
您可以添加条件,然后添加where RecordId='11'
或@input