Non testato. Comunque l'idea c'è.
Select a.store_ric, a.testo_ric, a.prezzo_ric, a.fatturato_sing, a.maxv
from
(select store_ric, testo_ric, prezzo_ric, fatturato_sing, max(n_venduti) as maxv)
from tabella
where n_venduti>100 group by store_ric) a
inner join
(Select store_ric, testo_ric, max(n_venduti) as maxv from tabella group by store_ric, testo_ric) b
on a.store_ric = b.store_ric and a.testo_ric = b.testo_ric and a.maxv = b.maxv
order by a.maxv desc limit 10


Rispondi quotando