答案 0 :(得分:0)
您需要在电话用户名上排名。这将给你排名。
SELECT *, (select count(table1.username)
from table1 as tbl2
where table1.tel >= tbl2.tel and table1.username=tbl2.username)
as rank from table1 ORDER BY username,tel;
如果您的活动列始终为T,那么您可以在查询中对其进行硬编码,如下所示:
SELECT *, (select count(table1.username) from
table1 as tbl2
where table1.tel >= tbl2.tel and table1.username=tbl2.username) & 'T'
as rank from table1 ORDER BY username,tel
如果Table1中的活动列可能不同,则将第一个查询保存为query1并使用此连接查询:
SELECT Table1.active & query1.rank AS Expr1, Table1.tel, Table1.username
FROM Table1 INNER JOIN Query1 ON Table1.ID = Query1.ID;
如果您没有ID列,请将其添加到Table1。