How to convert Sql orderby clause with Case Statement into JOOQ?

安稳与你 提交于 2019-12-13 06:36:05

问题


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 
END

How to write the above line using JOOQ?


回答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))


来源:https://stackoverflow.com/questions/19654784/how-to-convert-sql-orderby-clause-with-case-statement-into-jooq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!