Select a.id,a.good_id,a.name from orders as a left join orders as b on a.good_id=b.good_id and a.id<b.id group by a.id,a.name,a.good_id HAVING count(b.id)<10 order by a.good_id desc;
Select a.id,a.good_id,a.name from orders as a left join orders as b on a.good_id=b.good_id and a.id<b.id group by a.id,a.name,a.good_id HAVING count(b.id)<10 order by a.good_id desc;