Используйте следующий запрос
select customer_id, product_name, count(product_name) as mostcount from `products` where product_name='bajari' group by customer_id having count(product_name) =
( select max(mostcount) as highest_total
from (
select customer_id
, count(product_name) as mostcount
from `products` where product_name='bajari'
group
by customer_id
) as t
);
Для пошагового решения, пожалуйста, проверьте то же решение для здесь .
Надеюсь, это поможет вам !!