We made a significant improvement to support more scalar subselects in the 8.7 release. E.g. this works now but failed in 8.5:
create table salesperson(id int, name varchar(30), specialty varchar(30));
create table sale(sid int, sp_id int, d date, amount float, category varchar(30));
insert salesperson values(1,"Jane","condos"),(2,"Bob","houses");
insert sale values(1, 1, now(), 100, "condos");
insert sale values(2, 1, now(), 350, "condos");
insert sale values(3, 1, now(), 700, "houses");
insert sale values(4, 2, now(), 200, "condos");
insert sale values(5, 2, now(), 250, "condos");
insert sale values(6, 2, now(), 300, "houses");
select sp.name, s.*
from salesperson sp, sale s
where sp.id = s.sp_id
and s.amount >= (select avg(s2.amount)
from sale s2
where sp.id = s2.sp_id
OR (sp.specialty = s2.category) );
The OR in the subselect is the issue.
Internally we call the improvement a generalized subselect to join (SSTJ) transformation.