sendou.ink/app/db/models/badges/ownersByBadgeId.sql
2022-08-14 12:22:04 +03:00

16 lines
339 B
SQL

select
count("BadgeOwner"."badgeId") as count,
"User"."id",
"User"."discordId",
"User"."discordName",
"User"."discordDiscriminator"
from
"BadgeOwner"
join "User" on "User"."id" = "BadgeOwner"."userId"
where
"BadgeOwner"."badgeId" = @id
group by
"User"."id"
order by
count desc,
"User"."discordName" collate nocase asc