sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Cannot use column alias in where clause #317

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I want to use calculated column alias in where clause. While I use it in order 
by clause, everything is ok.

Error:
select *, distanceEarth(lat, lon, 50.245284, 16.163576) as dist 
from location 
where dist < 50 
order by dist

Workaround:
select *, distanceEarth(lat, lon, 50.245284, 16.163576) as dist 
from location 
where distanceEarth(lat, lon, 50.245284, 16.163576) < 50 
order by dist

Note: distanceEarth is custom function alias

In workaround you can see that I use calculation two times: first for order by 
clause and second for where clause.

Am I missing something?

Thanks for response
Ivos

Original issue reported on code.google.com by bedla.cz...@gmail.com on 27 Apr 2011 at 9:29

GoogleCodeExporter commented 8 years ago
Hi,

This is not a bug, it's a question. Please use the Google Group for questions.

select * from (select *, distanceEarth(lat, lon, 50.245284, 16.163576) as dist 
from location) where dist < 50 order by dist;

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 27 Apr 2011 at 8:18