> I find it annoying that you can't use aliases in where
statements
This isn't really (or... "at all") a CF question. You're
better off asking
this sort of thing on a SQL Server forum.
You could use a derived table, I guess:
select top 1 num
from (
SELECT
CAST(amount
/ ( CASE WHEN ISNULL(rate, 0) <> 0 THEN
rate
ELSE 1
END ) AS NUMERIC(10, 2)) AS num
FROM table
)
where num > 1
order by num
(that might not preserve the intent of you SQL (sorry: it's
late, I'm
tired), but you get the idea.
--
Adam