Skip to content Skip to sidebar Skip to footer

How To Convert Sql Orderby Clause With Case Statement Into Jooq?

I want to convert Sql orderby clause with Case using JOOQ.and BillAmount is of BigDecimal datatype. ORDER BY CASE WHEN (BillAmount <= 0) THEN BillAmount ELSE BillNumber EN

Solution 1:

Your best option is to directly translate your SQL clause to a corresponding jOOQ clause using the CASE expression (as documented in the manual)

.orderBy(DSL.decode().when(BillAmount.le(0), BillAmount)
                     .otherwise(BillNumber))

Post a Comment for "How To Convert Sql Orderby Clause With Case Statement Into Jooq?"