Re: Promedio de campos interval

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: jsgarcia(at)seguridad(dot)unam(dot)mx
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Promedio de campos interval
Date: 2009-06-11 19:59:05
Message-ID: 20090611195905.GE6401@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

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

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2009-06-11 20:01:10 Re: sigo con crosstab y los problemas
Previous Message Alvaro Herrera 2009-06-11 19:57:22 Re: sigo con crosstab y los problemas