> > 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
: 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
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
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
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
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