In MySQL, how to fetch limit values for all id's

Solution 1:

If your MySql version supports window functions you could try the following

with t as (
    select selected_date, id, price1, price2,
    Row_Number() over(partition by id order by selected_date desc) rn
    from values 
    where id in (100, 101)
)
select selected_date, id, price1, price2
from t
where rn <= 90;