CASE

From: Rudi Starcevic <rudi(at)oasis(dot)net(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: CASE
Date: 2003-04-08 08:29:07
Message-ID: 3E928853.7090801@oasis.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I'm trying to find the maximum date then compare that date to see if I
have any current events to show.
Here is an SQL snippet ( the e.edate field is of type 'date' )

CASE
WHEN COALESCE( MAX(e.edate),'2003-01-01') >= now()::date THEN 'events'
ELSE 'noevents'
END as myevents,

It works fine for those events who do have dates greater or equal to now and
also for those events who have a NULL value.

However there is one event which is in the past '2003-04-01' which is
still coming up as 'events' instead of 'noevents'.
I think there may be something wrong with my CASE SQL clause.

I can't see any problem right now can anyone here see one ?

Thank you kindly
Regards
Rudi.

Responses

  • Re: CASE at 2003-04-08 09:40:39 from Victor Yegorov

Browse pgsql-sql by date

  From Date Subject
Next Message Victor Yegorov 2003-04-08 09:40:39 Re: CASE
Previous Message Jan Wieck 2003-04-07 21:41:00 Re: Creating a foreign key on the Union of two tables