How to add sequenced number based on sorted value in query in Access

后端 未结 2 1702
失恋的感觉
失恋的感觉 2021-01-25 22:45

I have a query which returns some values (att1). I would like also to have next to it the values which would represent a sorted order of att1. Somethin

2条回答
  •  野的像风
    2021-01-25 22:51

    Assuming a table name of table1, The following should yield the desired result:

    select a.att1, (select count(*) from table1 b where b.att1 <= a.att1) as att2
    from table1 a;
    

    For every record, the query calculates the number of records less than or equal to the current record, which is then output as the sort index.

提交回复
热议问题