How can sort query by aggregate function?

9 views
Skip to first unread message

Евгений Афанасьев

unread,
Jan 22, 2021, 3:44:24 PM1/22/21
to ScalikeJDBC Users Group
Hello, every one. I need some help with ScalikeJDBC, thats why this question for its users.
my project have next tables: Posts, Users, Votes. Post one-to-many Votes, Post many-to-one users. I want to get All posts with comments and user and order by comments count. First problem was uncorrect limit, but I fixed this by sub-queries. But how can I sort posts by count queries ?
I know how to do it in SQL. How can i order by count(v.voteId) in DSL ? .orderBy(x(count(v.voteId))) not working
In this gist you can find my DSL function and SQL script: https://gist.github.com/afanasevek/82fb6b0f09d7f74565b55adf9879d582
Reply all
Reply to author
Forward
0 new messages