Re: Estadistica por fechas

From: raul andrez gutierrez alejo <raulandrez(at)gmail(dot)com>
To: Aland Laines <aland(dot)laines(at)gmail(dot)com>
Cc: gilberto(dot)castillo(at)etecsa(dot)cu, POSTGRES <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Estadistica por fechas
Date: 2014-12-03 22:38:55
Message-ID: CAHQFj70_8_KdWtj-faOJqyj7ZUb=p_54i+KuxG6YWD9wnzhu=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola.
seria algo asi.

SELECT TO_CHAR(fecha_ingreso,'YYYY-MM') AS mes,
count(*)FROM tablaWHERE fecha_ingreso IS NOT NULL
AND fecha_termino IS NULLGROUP BY
TO_CHAR(fecha_ingreso,'YYYY-MM')ORDER BY
TO_CHAR(fecha_ingreso,'YYYY-MM')

nota:el order by genera mucha carga computacional

El 3 de diciembre de 2014, 17:31, Aland Laines <aland(dot)laines(at)gmail(dot)com>
escribió:

> Hola Gilberto, los tickets no necesariamente son cerrados el mismo mes,
> los que no son cerrado estan en null, pero quieren un historico mes a mes y
> por año, yo al menos quisiera lograr la estadistica mes a mes del ultimo
> año.
>
> Saludos,
>
>
> [image: --]
> Aland Laines Calonge
> [image: http://]about.me/aland.laines
> <http://about.me/aland.laines>
> *programador de aplicativos web*
> Twitter: @lainessolutions
> Comunidad CakePHP en Español Google+
> <https://plus.google.com/communities/106077549014949879129>
>
> El 3 de diciembre de 2014, 17:02, Gilberto Castillo <
> gilberto(dot)castillo(at)etecsa(dot)cu> escribió:
>
>>
>>
>> > Hola compañeros, tengo una consulta que me tiene trabado, tengo una
>> tabla
>> > de tickets:
>> >
>> > id numero fecha_ingreso fecha_termino
>> >
>> > La consulta que me piden es cuantos tickets estuvieron activos (no
>> fueron
>> > finalizados) al final de cada mes.
>>
>> Supongo que todo el que tenga fecha_termino en null o algo así... aun esta
>> abierto.
>>
>> ¿Un tickets, debe ser obligatoriamente cerrado en el mismo mes?
>>
>> Saludos,
>> Gilberto Castillo
>> La Habana, Cuba
>>
>> ---
>> This message was processed by Kaspersky Mail Gateway 5.6.28/RELEASE
>> running at host imx3.etecsa.cu
>> Visit our web-site: <http://www.kaspersky.com>, <http://www.viruslist.com
>> >
>>
>>
>

--
Raul Andres Gutierrez Alejo

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Hellmuth Vargas 2014-12-04 02:57:17 Re: Estadistica por fechas
Previous Message Aland Laines 2014-12-03 22:31:15 Re: Estadistica por fechas