select DISTINCT a.id FROM (
(select distinct t.id from tcompany_kpi t where 1 =1 and t.id in (37395,37396,37397,37398 ) and annual_return >= 0.1 and annual_return <= 0.2 )
union ALL
(select distinct t.id from tcompany_kpi t where 1 =1 and t.id in (37395,37396,37397,37398,37399 ) order by profit_ratio desc LIMIT 0,3 )
union ALL
(select distinct t.id from tcompany_kpi t where 1 =1 and t.id in ( 37395,37396,37397,37398 ) and annual_volatility >= 0.1 and annual_volatility <= 0.2 ) ) a
GROUP BY a.id HAVING COUNT(*) =3