数据排序:
row_number() 123
rank(() 113
dense_rank() 112
merge 改写有聚合的update
merge into target_table o
using relation_table t on (t.condition1=o.condition1)
when matched then update
set o.field1=t.field8
min(mc) keep (DENSE_RANK first ORDER BY sl) over(partition by id):id等于1的数量最小的(DENSE_RANK first )为
1 111 1
1 222 1
在这个结果中取min(mc) 就是111
max(mc) keep (DENSE_RANK first ORDER BY sl) over(partition by id)
取max(mc) 就是222;
min(mc) keep (DENSE_RANK last ORDER BY sl) over(partition by id):id等于1的数量最大的(DENSE_RANK first )为
1 555 3
1 666 3
在这个结果中取min(mc) 就是222,取max(mc)就是666
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8568259/viewspace-2107252/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8568259/viewspace-2107252/