如何将带有Case语句的Sql orderby子句转换为JOOQ? [英] How to convert Sql orderby clause with Case Statement into JOOQ?
本文介绍了如何将带有Case语句的Sql orderby子句转换为JOOQ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用JOOQ
将Case转换为Sql
orderby子句,而BillAmount的数据类型为BigDecimal
.
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
如何使用JOOQ
编写以上行?
推荐答案
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))
这篇关于如何将带有Case语句的Sql orderby子句转换为JOOQ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文