SELECT stat.pg_id, SUM(stat.view_cou) as view_cou, n.*, cat.name as catname, comp.fullname as compfullname FROM `popnano_stat`.reit_www_daily as stat LEFT OUTER JOIN `popnano`.company_product as n ON n.id = stat.pg_id LEFT OUTER JOIN `popnano`.catalog as cat ON n.catalogid = cat.id LEFT OUTER JOIN `popnano`.company as comp ON n.companyid = comp.id WHERE n.published=1 AND stat.pg_grp='7' AND (stat.y >= 2019 AND stat.m >= 4 AND stat.d >= 15) AND (stat.y <= 2019 AND stat.m <= 4 AND stat.d <= 21) GROUP BY stat.pg_id ORDER BY view_cou DESC, stat.ip_cou DESC LIMIT 0, 10