select count(*) as records from (select DISTINCT e.*, pe.*, p.nombre as nombrePrecio from tblti_productos e JOIN precios_escorts pe on (e.idproducto=pe.idescort) JOIN precios p on (p.id=pe.idprecio) where idcategoria = and activa=1 GROUP BY e.nombre order by nombre asc) execPage