'How to find specific rank(order) using querydsl

I would like to work on a table grouped by users to rank by studytime sum.

  • The table saved based on the sum of studytime is not in the original db and is created with the code below.
 List<RankingRankGetRes> userRankInfo = jpaQueryFactory.select(new QRankingRankGetRes(qStudyTime.user.nickname, qStudyTime.user.department.name, qStudyTime.time.sum())).from(qStudyTime)
.groupBy(qStudyTime.user).orderBy(qStudyTime.time.sum().desc()).fetch();
  • How to use this to create a query that returns a ranking based on studytime?
  1. The rank() function is not provided in JPAQueryFactory. Is there a way to do that query without this?

  2. Is there a way to do it using SQLExpressions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source