From 5e18698dfc7046f38d77bb1cdc5e04d0f2c1a9e0 Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 21 Feb 2026 14:58:15 +0000 Subject: [PATCH] Add q01-all-games-scores.sql --- q01-all-games-scores.sql | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 q01-all-games-scores.sql diff --git a/q01-all-games-scores.sql b/q01-all-games-scores.sql new file mode 100644 index 0000000..af7a5b9 --- /dev/null +++ b/q01-all-games-scores.sql @@ -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;