I'm writing my first subquery within an outer query and can't work out what I'm doing wrong:
from the entry table (event_id, horse_id, place)
and the horse table (horse_id, horse_name)
I have to list the horse_id and horse_name for each horse that has been placed in the top 3 (ie, got place 1, 2 or 3) two or more times.
this is my subquery, which worked:
select H.horse_id, H.horse_name
from entry E, Horse H
where E.horse_id = H.horse_id
and E.place < ‘4’;
this is the subquery within the outer query, which didn't work:
select H.horse_id, H.horse_name
from horse H
where 2 <= (select count(*)
from entry E, horse H
where E.horse_id = H.horse_id
and E.place < ‘4’);
Can anyone spot my error, please?