Reputation: 2579
I need to trunc()
a double precision
number that i get from sum()
. Because trunc()
only accepts numeric
i have to cast the double precision
to numeric
. In raw SQL this is straight forward:
trunc(cast(sum(...) as numeric), 0)
I tried the same thing using JOOQ:
trunc(sum(...).cast(???), 0)
How can i cast to numeric using JOOQ?
Upvotes: 2
Views: 488
Reputation: 24161
You are looking for .cast(SQLDataType.NUMERIC)
In jOOQ version 3.11 onwards the use of PostgresDataType.NUMERIC
has been deprecated, but this is an alternative approach for older versions:
.cast(PostgresDataType.NUMERIC)
Upvotes: 3