Not the same scenario but I got the similar error / issue so below is how i got it and then how I resolved it.
I was using a timestamp table coulmn in a calculation and using that calculation to create new column for rising column as follows (b was timestamp table coulmn):
select a,b,extract(hour from b) as c from myTable
where c > ?
order by c asc
Issue here was I cannot use an alias c in where clause, so db connect was giving me the error mentioned in question. This is how I resolved it by writing expression twice:
select a,b,c from
( select a,b, extract(hour from b) as c from myTable )
where c > ?
order by c asc
... View more