Problem
Right now groupBy doesn't support ordering by an aggregate.
model User {
id Int @id @default(autoincrement())
town String
}
List of towns, ordered by number of users in each town.
select town, count(town)
from user
group by town
order by count(town) asc
Suggested solution
client.user.groupBy({
orderBy: {
_count: {
town: 'desc'
}
}
})
Additional context
Problem
Right now groupBy doesn't support ordering by an aggregate.
List of towns, ordered by number of users in each town.
Suggested solution
Additional context
groupBy#4893 (comment)