Re: Promedio de campos interval (resuelto)

From: jsgarcia(at)seguridad(dot)unam(dot)mx
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Promedio de campos interval (resuelto)
Date: 2009-06-11 23:06:12
Message-ID: 20090611180612.nw9252or0ysc8o0c@correo.seguridad.unam.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Bueno pues ya pude resolver lo del group by y el promedio

SELECT AVG(t.tiempo_resolver), date_part('month', c.dia_hora) FROM
v_atendido a, v_concluido c, tiempo_resolver t WHERE
a.caso_id=c.caso_id AND a.caso_id=t.caso_id GROUP BY date_part
ORDER BY date_part ;

Gracias¡¡
___________________________________________________________________________

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> ha escrito:

> jsgarcia(at)seguridad(dot)unam(dot)mx escribió:
>> Buen día, alguno de ustedes podría ayudarme a hacer el promedio del
>> tiempo pero agrupado por mes para la siguiente tabla???:
>>
>>
>>
>> tiempo | date_part
>> -----------------------+-----------
>> 10 days 08:02:40 | 11
>> 10 days 02:27:53 | 12
>> 4 days 04:27:23 | 11
>> 00:00:22 | 11
>> 12 days 02:58:19 | 11
>> 17 days 02:34:31 | 4
>> 00:03:42 | 11
>> 07:05:03 | 10
>> 4 days 21:33:36 | 9
>>
>> He intentado con AVG(tiempo) y GROUP BY date_part pero no se resuelve.
>> Nos e si deba agregarle algo más.
>
> Creo que necesitas un
> group by date_trunc('month', fecha)
>
> --
> Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4
> "Executive Executive Summary: The [Windows] Vista Content Protection
> specification could very well constitute the longest suicide note
> in history."
> Peter Guttman,
> http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt
> --
> TIP 9: visita nuestro canal de IRC #postgresql-es en irc.freenode.net
>

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Attachment Content-Type Size
Clave PGP =?iso-8859-1?b?cPpibGljYQ==?= application/pgp-keys 1.7 KB

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Giorgio PostgreSQL 2009-06-11 23:16:51 Re: Ayuda con Fechas
Previous Message Sergio Gabriel Rodriguez 2009-06-11 22:51:24 pg_restore: no restaura indices ni triggers