Re: order of clauses

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: order of clauses
Date: 2001-02-16 19:02:49
Message-ID: Pine.BSF.4.21.0102161100570.12403-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Well, it doesn't solve the ordering question, but you could
use a where something like this I guess:
where y>0 and (x/(case when y=0 then 1 else y end))>1

On Wed, 14 Feb 2001, Patrick Welche wrote:

> create table vals (
> x float,
> y float
> );
> insert into vals values (2,4);
> insert into vals values (2,2);
> insert into vals values (2,1);
> insert into vals values (2,0);
> select x/y from vals where y>0 and x/y>1;
>
> will give a divide by zero error as A=(y>0) and B=(x/y>1) can be evaluated in
> any order (A and B = B and A). I obviously would like (y>0) to happen first,
> but I don't see how this can be achieved.. Any ideas?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bryan White 2001-02-16 19:09:42 Re: Number of Connections
Previous Message Rod Taylor 2001-02-16 19:01:07 SPI_finish()