| 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 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Moko Verdoso | 2006-02-27 14:56:10 | Re: COUNT |
| Previous Message | Alvaro Herrera | 2006-02-27 13:53:35 | Re: COUNT |