From: | Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk> |
---|---|
To: | pgsql-general(at)PostgreSQL(dot)org |
Subject: | Re: Nulls in timestamps |
Date: | 2005-07-16 10:45:18 |
Message-ID: | 42D8E53E.F0E92C95@telemetry.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks, that looks useful. I'll investigate once I've got the servers upgraded
and replication running.
Bruno Wolff III wrote:
>
> On Wed, Jul 13, 2005 at 18:15:12 +0000,
> markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk wrote:
> > Many thanks Tom. Inconvenient from the point of view of the application
> > but still useful information.
> >
> > The situation is that I've got a query with numerous subselects, each of
> > which has to return exactly one row so I was doing a union with a nulled
> > record then selecting the most recent: obviously I need to see bona-fide
> > data if it's there.
>
> you can order by datecol is null, datecol desc to get the most recent
> non null date. For example:
> area=> select day from (select 'today'::date as day union select
> 'tomorrow'::date as day union select null as day) as un order by day is null,
> day desc;
> day
> ------------
> 2005-07-16
> 2005-07-15
>
> (3 rows)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
From | Date | Subject | |
---|---|---|---|
Next Message | Janning Vygen | 2005-07-16 11:58:43 | Re: PLPGSQL how to get transaction isolation level info |
Previous Message | Tino Wildenhain | 2005-07-16 09:16:49 | Re: PostgreSQL select |