Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > SQL
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-05-2006
Avatar de apicito
apicito apicito is offline
Miembro
 
Registrado: may 2003
Ubicación: Ourense
Posts: 341
Poder: 22
apicito Va por buen camino
Problema con group by

Porqué si a esta consulta:
Código Delphi [-]
      SQL.Add('select A.SESASU_GRUPO,A.SESASU_ASUNTO as ASUNTO');
      SQL.Add('from SES'+Part+'ASU A join SES'+Part+'GRU G on G.SESGRU_CODIGO=A.SESASU_GRUPO');
      Sql.Add('where G.SESGRU_MOSTRAR=1');
      SQL.Add('and A.SESASU_SESION='+#39+inttostr(SesCodigo)+#39);
      SQL.Add('union');
      if Datos.CargaIni('Servidor','SOperativo')='Linux' then
        SQL.Add('select A.SESASU_GRUPO,string2blob(G.SESGRU_DESCRIP) as ASUNTO')
      else
        SQL.Add('select A.SESASU_GRUPO,F_STRBLOB(G.SESGRU_DESCRIP) as ASUNTO');
      SQL.Add('from SES'+Part+'ASU A join SES'+Part+'GRU G on G.SESGRU_CODIGO=A.SESASU_GRUPO');
      Sql.Add('where G.SESGRU_MOSTRAR=0');
      SQL.Add('and A.SESASU_SESION='+#39+inttostr(SesCodigo)+#39);
      Sql.Add('group by A.SESASU_GRUPO,G.SESGRU_DESCRIP');
le añado en los select el campo A.SESASU_NUMERO que es un contador dentro del grupo (A.SESASU_GRUPO) de esta forma:
Código Delphi [-]
      SQL.Add('select A.SESASU_GRUPO,A.SESASU_ASUNTO as ASUNTO,A.SESASU_NUMERO');
      SQL.Add('from SES'+Part+'ASU A join SES'+Part+'GRU G on G.SESGRU_CODIGO=A.SESASU_GRUPO');
      Sql.Add('where G.SESGRU_MOSTRAR=1');
      SQL.Add('and A.SESASU_SESION='+#39+inttostr(SesCodigo)+#39);
      SQL.Add('union');
      if Datos.CargaIni('Servidor','SOperativo')='Linux' then
        SQL.Add('select A.SESASU_GRUPO,string2blob(G.SESGRU_DESCRIP) as ASUNTO,A.SESASU_NUMERO')
      else
        SQL.Add('select A.SESASU_GRUPO,F_STRBLOB(G.SESGRU_DESCRIP) as ASUNTO,A.SESASU_NUMERO');
      SQL.Add('from SES'+Part+'ASU A join SES'+Part+'GRU G on G.SESGRU_CODIGO=A.SESASU_GRUPO');
      Sql.Add('where G.SESGRU_MOSTRAR=0');
      SQL.Add('and A.SESASU_SESION='+#39+inttostr(SesCodigo)+#39);
      Sql.Add('group by A.SESASU_GRUPO,G.SESGRU_DESCRIP');
me da error de :
Invalid expression in the Select list (not contained in either an aggregate function or the GROUP BY clause).
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
consultas anidadas: group by dentro otro group by DobleSiete SQL 7 31-01-2005 14:59:31
Select...group By JorgeBec SQL 2 02-12-2004 17:27:25
problema con group by raudelink SQL 2 18-10-2004 21:19:05
Group Header, Detail y Footer Group en la misma pagina MarcelRuz Impresión 0 20-04-2004 23:27:14
Problema con Group en qreport seken Impresión 1 18-06-2003 23:32:50


La franja horaria es GMT +2. Ahora son las 05:00:14.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi