Skip to content

Commit

Permalink
fix: row rank 쿼리 문법 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hun-ca committed Jul 29, 2024
1 parent 5e05b09 commit a657727
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ class ArticleViewCountDao(
}

fun selectRankByViewsQuery(query: SelectRankByViewsQuery) = dslContext
.select(field("offset"))
.select(field("row_rank_tb.offset", Long::class.java))
.from(
dslContext.select(
ARTICLE_VIEW_COUNT.ARTICLE_ID,
rowNumber().over(orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc())).`as`("offset")
).from(ARTICLE_VIEW_COUNT.`as`("RankedRows"))
dslContext
.select(
ARTICLE_VIEW_COUNT.ARTICLE_ID,
rowNumber().over(orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc())).`as`("offset")
)
.from(ARTICLE_VIEW_COUNT)
.asTable("row_rank_tb")
)
.where(field("RankedRows.article_id").eq(query.articleId))
.where(field("row_rank_tb.${ARTICLE_VIEW_COUNT.ARTICLE_ID.name}")!!.eq(query.articleId))
.query

fun selectArticlesOrderByViews(query: SelectArticlesOrderByViewsQuery): Set<SelectArticleViewsRecord> {
Expand Down

0 comments on commit a657727

Please sign in to comment.