Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clausesyntax error: SELECT count(id) AS numrows FROM table_product where id IN (select id_pro from table_protag where id_tag='798') order by stt asc,ngaytao desc