Re: Agrupamiento de Segundo Nivel

From: Rusel Fichi <rdfs(dot)ing(at)gmail(dot)com>
To: Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar>
Cc: pgsql-es-ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Agrupamiento de Segundo Nivel
Date: 2016-05-10 12:19:31
Message-ID: CAMiTfwJTEhCra9JWmd5yEW_-e850=752M-W6Cbw8kbai7oAcqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Claro, entiendo,

Lo que hice fue dar un ejemplo de lo que quería, espero esto ayude.

La tablas de los históricos de envíos es:

CREATE TABLE historico_envios (
idHISTORICO_ENVIOS serial NOT NULL,
idAlerta_Generada int(11) NOT NULL,
idMedio_Contacto int(11) NOT NULL,
idEstado_Envio int(11) NOT NULL,
CodigoConfirmacion varchar(15) NULL,
Mensaje varchar(10000) NULL,
RutaFicheroAdjunto varchar(255) NULL,
NumeroEnvio int(11) NOT NULL,
FechaHora datetime NOT NULL,
FechaHoraUTC datetime NOT NULL,
idMensaje int(11) NOT NULL,
idEnvio int(11) NOT NULL,
dtmfDetectado varchar(20) NOT NULL,
tipoMedio varchar(20) NOT NULL,
destino varchar(45) NOT NULL,
destinatario varchar(500) NOT NULL,
grupo varchar(500) NOT NULL,
idGrupo int(11) NULL,
PRIMARY KEY (idHISTORICO_ENVIOS)
);

La tabla de los usuarios:

CREATE TABLE destinatario (
idDestinatario serial NOT NULL,
Nombre varchar(50) NOT NULL,
Apellidos varchar(50) NULL,
Empresa varchar(100) NULL,
FechaAlta datetime NOT NULL,
Habilitado int(11) NOT NULL,
prioridad int(11) NOT NULL,
Activado_SN varchar(1) NOT NULL,
TieneTurnos_SN varchar(1) NOT NULL,
Anotacion varchar(100) NULL,
Cargo varchar(100) NULL,
PRIMARY KEY (idDestinatario)
);

La tabla de alertas:

CREATE TABLE alerta_generada (
idALERTA_GENERADA serial NOT NULL,
idEmergencia_Generada int(11) NOT NULL,
idMensaje int(11) NOT NULL,
idEstado_Alerta int(11) NOT NULL,
idUsuario int(11) NOT NULL,
Titulo varchar(100) NOT NULL,
MensajeFinal text NOT NULL,
CampoMemo varchar(4000) NULL,
FechaAlta datetime NOT NULL,
MensajeInicial varchar(500) NULL,
FechaAltaUTC datetime NOT NULL,
PRIMARY KEY (idALERTA_GENERADA)
);

Este es mas o menos el query que llevo hecho:

SELECT he.idMedio_Contacto, he.destinatario, he.tipoMedio,
he.idMedio_Contacto,he.destino, he.NumeroEnvio, he.FechaHora,
ee.idEstado_Envio,
he.FechaHoraUTC, '' as idGrupoDestinatarios, he.grupo as nombreGrupo,
he.dtmfDetectado
FROM HISTORICO_ENVIOS he
INNER JOIN ESTADO_ENVIO ee ON he.idEstado_Envio = ee.idEstado_Envio
INNER JOIN ALERTA_GENERADA ag ON he.idAlerta_Generada = ag.idAlerta_Generada
WHERE ag.idEmergencia_Generada= ?

No he podido hacer la agrupación aun porque no tengo idea de como hacerla
según el ejemplo anterior.

El 10 de mayo de 2016, 13:12, Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar> escribió:

> Sin conocer la estructura de la/s tabla/s, y un lotecito de prueba, no veo
> como alguien podria ayudarte.
>
> Gerardo
>
> ----- Mensaje original -----
> > De: "Rusel Fichi" <rdfs(dot)ing(at)gmail(dot)com>
> > Para: "pgsql-es-ayuda" <pgsql-es-ayuda(at)postgresql(dot)org>
> > Enviados: Martes, 10 de Mayo 2016 7:56:55
> > Asunto: [pgsql-es-ayuda] Agrupamiento de Segundo Nivel
> >
> >
> > Hola Estimados,
> >
> >
> > Tengo un inconveniente, actualmente estoy migrando unos reportes que
> > están escritos en PHP y debo pasar a Birt Report, ya he migrado
> > varios de los reportes que tienen consultas sencillas y medianamente
> > complejas, esta vez me encuentro con un reporte que debe tener dos
> > niveles de agrupamiento cosa que ya no puedo hacer en BIRT usando un
> > query normal , procesar la data a través de algun lenguaje no se si
> > sea posible con esta herramienta, por los momentos deberia poder
> > hacerlo en un solo query, es decir debería obtener algo así:
> >
> >
> >
>

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Herman Estaban 2016-05-10 18:00:06 Re: [pgsql-es-ayuda] Tamaño de Base Datos
Previous Message Gerardo Herzig 2016-05-10 11:12:58 Re: Agrupamiento de Segundo Nivel