标签: sql teradata
我需要根据以下记录对记录进行排名
基于b_id和优先级组合,需要按优先级顺序排列不同的组合,然后再次递归。 示例:
有人可以帮助我使用T-SQL
答案 0 :(得分:1)
您不想要排名,您想要row_number:
SELECT ..., Row_Number() Over (PARTITION BY acct_id ORDER BY rn, priority) AS rnk FROM ( SELECT ..., Row_Number() Over (PARTITION BY acct_id, priority ORDER BY b_id) AS rn FROM mytab ) AS dt