sql - Select only 3 best ranked after rank() over -


i'd select 3 best results of rank() function each partition

for instance, in query :

select id, rank() on (partition year order ...) rank table1 group year 

i'd have 3 best ranked every year.

i can manage making new :

select * ... rank <= 3 

but if have equalities, i'll more 3 row per year.

do have idea how solve ?

we have not information table , query structures, generic solution i'd suggest add row_number() on (order ... desc) rn , filter where rn = 1 here.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -