List<String> result = queryFactory
.select(member.age
.when(10).then("열살")
.when(20).then("스무살")
.otherwise("기타"))
.from(member)
.fetch();
List<String> result = queryFactory
.select(
new CaseBuilder()
.when(member.age.between(0, 20)).then("0 ~ 20살")
.when(member.age.between(21, 30)).then("21 ~ 30살")
.otherwise("기타")
)
.from(member)
.fetch();
NumberExpression<Integer> ageCase = new CaseBuilder()
.when(member.age.between(0, 20)).then(0)
.when(member.age.between(21, 30)).then(1)
.otherwise(2);
List<Tuple> fetch = queryFactory
.select(member.username, member.age, ageCase)
.from(member)
.orderBy(ageCase.desc())
.fetch();
댓글남기기