Add q01-all-games-scores.sql
This commit is contained in:
parent
540a615c8f
commit
5e18698dfc
1 changed files with 24 additions and 0 deletions
24
q01-all-games-scores.sql
Normal file
24
q01-all-games-scores.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- List all players odered by scores considering all games.
|
||||
|
||||
SELECT row_number() OVER (ORDER BY sum(score) DESC) || ' ' || status_user || ' con ' || sum(score) || ' ⭐'
|
||||
FROM (
|
||||
SELECT
|
||||
CASE
|
||||
WHEN accounts.domain IS NULL
|
||||
THEN '@' || accounts.username
|
||||
ELSE
|
||||
'@' || accounts.username || '@' || accounts.domain
|
||||
END AS status_user,
|
||||
CASE
|
||||
WHEN text ~ '1/6!' THEN 16
|
||||
WHEN text ~ '2/6!' THEN 8
|
||||
WHEN text ~ '3/6!' THEN 4
|
||||
WHEN text ~ '4/6!' THEN 2
|
||||
WHEN text ~ '5/6!' THEN 1
|
||||
ELSE 0
|
||||
END AS score
|
||||
FROM statuses, accounts
|
||||
WHERE text ~ 'ladeldia.cl' AND account_id = accounts.id
|
||||
)
|
||||
GROUP BY status_user
|
||||
ORDER BY sum(score) DESC;
|
||||
Loading…
Reference in a new issue