Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/08/2004, 08:06
Avatar de Reynier
Reynier
 
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 6 meses
Puntos: 1
duda con consulta

Tengo la siguiente consulta:
Código PHP:
SELECT *, COUNT(idpost) AS cant FROM jcgrm_preguntas WHERE idforo='".$show['idforo']."' GROUP BY idforoidpost 
pero me da este error:
Cita:
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.
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?
Estoy trabajando con PHP y MSSQL

Salu2
__________________
Ing. Reynier Pérez Mira