Error while fetching from (select distinct page_id from visitors_counts where client_id = 'd27b005c2de1e9f8391e7e0fcaff769a' and page_name = 'product.php' and page_id != '1768' order by entry_time desc limit 0, 10) as t1 Expression #1 of ORDER BY clause is not in SELECT list, references column 'afroqueenco_ecommerce.visitors_counts.entry_time' which is not in SELECT list; this is incompatible with DISTINCT