Código PHP:
SELECT *, COUNT(idpost) AS cant FROM jcgrm_preguntas WHERE idforo='".$show['idforo']."' GROUP BY idforo, idpost
Cita:
sabe alguien si tengo que agrupar por todos los campos que contiene esa tabla donde estoy haciendo el COUNT o que es lo que pasa?Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.idcat' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.nick' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.asunto' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.mensaje' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.fecha' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.visitas' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: Query failed in d:\WWW\www\includes\mainfunctions.php on line 666
No se pudo ejecutar la consulta SELECT *, COUNT(idpost) as cant FROM jcgrm_preguntas WHERE idforo='1' GROUP BY idforo, idpost. Error: Column 'jcgrm_preguntas.visitas' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.nick' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.asunto' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.mensaje' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.fecha' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: message: Column 'jcgrm_preguntas.visitas' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16) in d:\WWW\www\includes\mainfunctions.php on line 666
Warning: mssql_query() [function.mssql-query]: Query failed in d:\WWW\www\includes\mainfunctions.php on line 666
No se pudo ejecutar la consulta SELECT *, COUNT(idpost) as cant FROM jcgrm_preguntas WHERE idforo='1' GROUP BY idforo, idpost. Error: Column 'jcgrm_preguntas.visitas' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Estoy trabajando con PHP y MSSQL
Salu2