I´m learning PL SQL and I ran into a wall... 

So I have this ER model: [![enter image description here](https://i.stack.imgur.com/3B0Rw.png)](https://i.stack.imgur.com/3B0Rw.png)

And I want to get the Tripulante that has the most nHorasEfectuadas on each TipoAviao. (The id of the crew that has the most number of hours in each plane type).

I tried this :

```
SELECT T.IDTRIPULANTE, A.IDTIPOAVIAO, H.NHORASEFETUADAS
FROM TRIPULANTE T, HORASVOO H, TIPOAVIAO A
WHERE T.IDTRIPULANTE=H.IDTRIPULANTE 
and H.IDTIPOAVIAO=A.IDTIPOAVIAO 
and H.NHORASEFETUADAS = (select distinct max(o.NHORASEFETUADAS) 
FROM HORASVOO o 
WHERE o.IDTRIPULANTE = T.IDTRIPULANTE)
ORDER BY A.IDTIPOAVIAO;

```

But its returning ALL of the Tripulantes...(Only have 10)

[![enter image description here](https://i.stack.imgur.com/Op3N0.png)](https://i.stack.imgur.com/Op3N0.png)

Anything I'm doing wrong?

Thanks!