How can i sort a varchar field , i have taken ID as varchar and i want to sort it numerically.
We can do this in SQL with using
sql query ... order by 0+id desc
What i have in Jooq is
SimpleSelectFinalStep<ScoreCardRecord> q = factory.selectFrom(ScoreCard.SCORE_CARD)
.order开发者_C百科By(OloScoreCard.SCORE_CARD_ID.descending())
.limit(0,1);
Have you tried casting your VARCHAR
field into a numeric DataType
? You could do it like this:
factory.selectFrom(ScoreCard.SCORE_CARD)
.orderBy(OloScoreCard.SCORE_CARD_ID.cast(Integer.class).descending())
.limit(0, 1);
That way you could omit using "plain SQL fields"
精彩评论