sql >> Base de Datos >  >> RDS >> PostgreSQL

Algoritmo de coincidencia en SQL

select x.name, max(x.rank) 
from matches x
join (
    select name from matches where prop = 1 AND rank > 5
    intersect
    select name from matches where prop = 3 AND rank >= 8
) y
    on x.name = y.name 
group by x.name
order by max(rank);