https://kotlinlang.org logo
d

Damien

07/12/2021, 4:45 PM
Hi, how can I reference aliased columns from a subquery and use within a top-level function.. e.g. (greatly simplified for illustrative purposes)
select sum(subQuery.myCol + subQuery.myCol) from (select col as myCol) subQuery
I have my subselect working, have my column alias working, I can select by the alias (e.g.
select subQuery.myCol from (select...)
). But I cannot figure out how to construct further functions from the aliased columns. I essentially have multiple aliased columns in a subselect and I wish to multiply them in some way and query the result. Appreciate any insight! No idea where to start (QueryBuilder?)
Have managed to do this with an extension on Expression and
toQueryBuilder()..append
. Not sure if there is a better way but it works so I'm happy!
8 Views