Re: [GENERAL] order of clauses

2001-02-16 Thread Steve Wolfe
> > 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? I have one idea that would be nifty to implement. In some compilers, you

Re: [GENERAL] order of clauses

2001-02-16 Thread Dan Wilson
: SELECT a.x/b.y FROM vals a, (SELECT y FROM vals WHERE y > 0) b WHERE (a.x : / b.y) > 1; How much of a performance hit is there when using a select in the FROM clause? Is it even noticeable? How much better is it to create a static view? -Dan

Re: [GENERAL] order of clauses

2001-02-16 Thread Tom Lane
Patrick Welche <[EMAIL PROTECTED]> writes: > 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 id

Re: [GENERAL] order of clauses

2001-02-16 Thread Michael Fork
You didn't mention what version of Postgres, but in 7.1beta, you could do the following (pretty sure on the syntax): SELECT a.x/b.y FROM vals a, (SELECT y FROM vals WHERE y > 0) b WHERE (a.x / b.y) > 1; In anything else, you could try a view: CREATE VIEW valid_vals AS SELECT y FROM vals WHERE

Re: [GENERAL] order of clauses

2001-02-16 Thread Stephan Szabo
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 int

[GENERAL] order of clauses

2001-02-16 Thread Patrick Welche
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