两个函数细节记不住. 写个例子备注一下.

<pre class="sql">```
 select 
no, name, score
, rank() over(partition by no order by score asc) rk1
, rank() over(partition by no order by score desc) rk2
, row_number() over(partition by no order by score asc) rn1
, row_number() over(partition by no order by score desc) rn2

from  values 
 (1,'a',1), (1,'a', null),
 (1, 'b',2), (1, 'b',-2), (1, 'b',1)
 t (no, name, score)
;

结果

nonamescorerk1rk2rn1rn21b251511a132321b132431b-224241a\N1515


标签: partition, score, number, SQL, no, order, over, rank

相关文章推荐

添加新评论,含*的栏目为必填