Subject Re: Better way to write
Author rogervellacott
Using "between 100 and 200" would avoid one of the calculations.

Alternatively it might be faster to calculate the range, rather than
the value. Something on the lines of...

where p.price between (100*ex.rate/ex_to.rate) and
(200*ex.rate/ex_to.rate)



Roger Vellacott
Passfield Data Systems

--- In firebird-support@yahoogroups.com, Nick Upson <nick@u...>
wrote:
> This statement
>
> select p.price, p.deviza,
> p.price*(cast(ex.rate as double precision)/cast(ex_to.rate as
double
> precision)) as total
> from MyItems p
> where (total>100)and(total<200)
>
> complains about field total
>
> this one below works, but seems inefficient and has a maintenance
headache,
> easy to mistype 1 of the 3 identical statements
>
> select p.price, p.deviza,
> p.price*(cast(ex.rate as double precision)/cast(ex_to.rate as
double
> precision)) as total
> from MyItems p
> where (p.price*(cast(ex.rate as double precision)/cast(ex_to.rate
as
> double>100) and (p.price*(cast(ex.rate as double precision)/cast
(ex_to.rate
> as double<200)
>
> --
> Nick
> -----We Solve your Computer Problems---
> Founder & Listowner of the Prolifics User Group
> Panther, Ingres, UNIX, Interbase, Firebird - Available Shortly