X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 38935EFF80 for ; Thu, 5 Jun 2003 10:55:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 61793-10 for ; Thu, 5 Jun 2003 10:55:25 +0000 (GMT) Received: from natura.cebas.csic.es (natura.cebas.csic.es [161.111.146.9]) by svr1.postgresql.org (Postfix) with ESMTP id 9D5F0EFF6A for ; Thu, 5 Jun 2003 10:55:24 +0000 (GMT) Received: from natura.cebas.csic.es (localhost.localdomain [127.0.0.1]) by natura.cebas.csic.es (8.11.6/8.11.6) with ESMTP id h55AgDo27564 for ; Thu, 5 Jun 2003 12:42:13 +0200 Received: from there (equipo97.cebas.csic.es [161.111.146.97]) by natura.cebas.csic.es (8.11.6/8.11.6) with SMTP id h55AgCI27558 for ; Thu, 5 Jun 2003 12:42:12 +0200 Message-Id: <200306051042.h55AgCI27558@natura.cebas.csic.es> Content-Type: text/plain; charset="iso-8859-15" From: javier garcia - CEBAS Organization: CEBAS-CSIC To: pgsql-sqL Subject: EXTERN JOIN with WHEN query Date: Thu, 5 Jun 2003 12:55:14 +0200 X-Mailer: KMail [version 1.3.2] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: * X-Archive-Number: 200306/36 X-Sequence-Number: 13794 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