【发布时间】:2018-04-04 23:06:12
【问题描述】:
我正在尝试在 jooq 中重现这个 MySQL 查询
select case
when year(d.date) - p.birth_year < 5 then '<5'
else '5+'
end as age
from partners p join departure d on d.id = p.id
到
this.schema().select(
DSL.decode().value(dateDiff(p.BIRTHDATE , date(d.DATE)))
.when(greaterThan(5), "above 5")
.when(lessThan(5), "under 5")
.otherwise("unknown").as("age"),
.from(p)
.join(d).on(d.ID.eq(p.ID))
【问题讨论】: