Skip site navigation (1) Skip section navigation (2)

Re: COUNT

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Javier Estévez CIFA Córdoba <javier(dot)estevez(dot)ext(at)juntadeandalucia(dot)es>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: COUNT
Date: 2006-02-27 14:43:41
Message-ID: 20060227144341.GE5755@surnet.cl (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
Javier Estévez CIFA Córdoba escribió:
> Tengo la siguiente consulta:
> 
> SELECT "IdProvincia", "IdEstacion", count(*)
> FROM ria_day a JOIN ria_mes_avg_std b USING ("IdProvincia","IdEstacion",mes)
> WHERE a."IdProvincia"=b."IdProvincia" AND a."IdEstacion"=b."IdEstacion" AND
> a.mes=b.mes
> AND a."TempMax"<b."TxAVGmes"-2.0*"TxSTDmes" OR
> a."TempMax">b."TxAVGmes"+2.0*"TxSTDmes"
> GROUP by "IdProvincia", "IdEstacion"
> ORDER by  "IdProvincia", int2("IdEstacion")

Creo que seria algo asi

 SELECT "IdProvincia", "IdEstacion", count(*)
 FROM ria_day a LEFT JOIN ria_mes_avg_std b
   ON (a."IdProvincia" = b."IdProvincia" AND
       a."IdEstacion" = b."IdEstacion" AND
       a.mes = b.mes AND
       a."TempMax" BETWEEN b."TxAVGmes"-2.0*"TxSTDmes" AND b."TxAVGmes"+2.0*"TxSTDmes")
 GROUP by "IdProvincia", "IdEstacion"
 ORDER by  "IdProvincia", int2("IdEstacion")

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

  • Re: COUNT at 2006-02-27 12:23:37 from Javier Estévez CIFA Córdoba

Responses

  • Re: COUNT at 2006-03-01 08:18:37 from Javier Estévez CIFA Córdoba

pgsql-es-ayuda by date

Next:From: Moko VerdosoDate: 2006-02-27 14:56:10
Subject: Re: COUNT
Previous:From: Alvaro HerreraDate: 2006-02-27 13:53:35
Subject: Re: COUNT

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group