pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: javier garcia - CEBAS <rn001@cebas.csic.es>
To: pgsql-sqL <pgsql-sql@postgresql.org>
Subject: EXTERN JOIN with WHEN query
Date: Thu, 5 Jun 2003 12:55:14 +0200
Message-ID: <200306051042.h55AgCI27558@natura.cebas.csic.es> (raw)

Hi all;
This is a query that I guess is not very dificult, but I'm a newbie;
I've got a lot of tables, each of them with two columns:

SELECT * FROM precal; ->
  (date)     (real)
   fecha    | precipitacion
------------+---------------
 1996-01-01 |             0.6
 1996-02-01 |             0.7
...


But in this table there are some inexistents records (some missing days)
And I would like to create lists with a full list of dates and corresponding 
precipitation data, with gaps when the row didn't exist.
So; I've created a table with a complete series of dates from 1950 up to 
date, and made the query:

 SELECT fechas.fecha,precipitacion FROM fechas LEFT OUTER JOIN precal41 ON 
(fechas.fecha  = precal41.fecha);

This is perfect. But to make it better,  would like to include just the dates 
from the first one in the precal table. So, I've tried:

SELECT fechas.fecha,precipitacion FROM fechas LEFT OUTER JOIN precal41 ON 
(fechas.fecha  = precal41.fecha) WHEN fechas.fecha >= min(precal41.fecha);
With the answer:

ERROR:  parser: parse error at or near "WHEN"

Could you help me with this query?

Thanks and regards

Javier




view thread (2+ messages)  latest in thread

Message-ID: <200306051042.h55AgCI27558@natura.cebas.csic.es>
Permalink:  ../200306051042.h55AgCI27558@natura.cebas.csic.es/
Also on:    postgresql.org/message-id/200306051042.h55AgCI27558@natura.cebas.csic.es

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rn001@cebas.csic.es
  Subject: Re: EXTERN JOIN with WHEN query
  In-Reply-To: <200306051042.h55AgCI27558@natura.cebas.csic.es>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox