Pervasive SQL - 将排名列添加到已排序的记录集中

Pervasive SQL - Add a Rank Column to a Sorted Recordset

Pervasive 13, I'm looking for a way to add a rank 列中排序记录集。

例如,假设我有一个 customer table,它有一个名为 profit 的字段(维护该字段以指示每个客户的总利润)。除了按利润排序,我还想包括每个客户基于利润的排名,利润最高的客户排名 1,第二高的客户排名 2,依此类推。

select
     row_number() as "Rank"
    ,customer as "Customer"
from customers
order by profit desc

row_number(),以上是概念性的;它实际上在 Pervasive 13 中不起作用,但我希望有其他东西可以实现相同的概念来生成如下所示的记录集:

Rank |Customer         |
-----+-----------------+
  1  |LUCRATIVE TECH   |
  2  |ROY INDUSTRIES   |
  3  |CRON INC.        |
  4  |FLEX PRODUCTS    |
  5  |CATCO CO.        |

仅使用 SQL 查询,如何在 Pervasive 13 中生成包含 rank 列的记录集?

使用更小/制造的数据集,这样的事情似乎对我有用。

create table customers (id identity, customer char(20), profit integer);

insert into customers values (0,'cust1',5);
insert into customers values (0,'cust2',4);
insert into customers values (0,'cust3',1);
insert into customers values (0,'cust4',3);
insert into customers values (0,'cust5',2);
insert into customers values (0,'cust6',2);

select 
(select 1 + count(*)
        from customers c2
        where c2.profit < c.profit
       ) as "rank"
    , c.*
from customers c
order by "rank" 

结果:

       rank            id   customer                    profit
===========   ===========   ====================   ===========
          1             3   cust3                            1
          2             5   cust5                            2
          3             4   cust4                            3
          4             2   cust2                            4
          5             1   cust1                            5