pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: MaXX <bs139412@skynet.be>
To: pgsql-sql@postgresql.org
Subject: Re: generate_series to return row that doesn't exist in
Date: Fri, 24 Mar 2006 21:54:28 +0100
Message-ID: <200603242154.29175.bs139412@skynet.be> (raw)
In-Reply-To: <1143232952.3625.6.camel@state.g2switchworks.com>
References: <200603242130.57851.bs139412@skynet.be>
	<1143232952.3625.6.camel@state.g2switchworks.com>

On Friday 24 March 2006 21:42, Scott Marlowe wrote:
> More than likely you need a left join and a case statement.
>
> select <selectlist>, case when a.date is null then 0 else a.date end
> from (select * from generate_series() -- magic to get dates goes here)
> as p left join maintable as a on (p.date=a.date);
>
> There may be some small syntax error in there, as I've not tested it.
> The relavent pages are:
>
> case:
> http://www.postgresql.org/docs/8.1/static/functions-conditional.html
>
> joins:
> http://www.postgresql.org/docs/8.1/static/queries-table-expressions.html
Perfect!!
Time to RTFM again...

Thanks,
-- 
MaXX



view thread (3+ messages)

Message-ID: <200603242154.29175.bs139412@skynet.be>
Permalink:  ../200603242154.29175.bs139412@skynet.be/
Also on:    postgresql.org/message-id/200603242154.29175.bs139412@skynet.be

 · 

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: bs139412@skynet.be
  Subject: Re: generate_series to return row that doesn't exist in
  In-Reply-To: <200603242154.29175.bs139412@skynet.be>

* 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