Mateu
04/16/2024, 9:54 AMCREATE TABLE highScore (
id INTEGER NOT NULL,
name TEXT NOT NULL,
points INTEGER NOT NULL
);
mySelect:
SELECT
name,
RANK () OVER (
ORDER BY points DESC
) rank
FROM highScore
;
With potsgresql I get:
Compiling with dialect app.cash.sqldelight.dialects.postgresql.PostgreSqlDialect
file.sq: (29, 15): ',', <compound operator real>, FOR, FROM, GROUP, HAVING, LIMIT, OFFSET, ORDER or WHERE expected, got '('
27 SELECT
28 name,
29 RANK () OVER (
^
30 ORDER BY points DESC
31 ) rank
32 FROM highScore
With sqlite:
Failed to compile SqlCompoundSelectStmtImpl(COMPOUND_SELECT_STMT): [] :
SELECT
name,
row_number() OVER (ORDER BY points DESC) AS rank
FROM highScore
Is there something else that need to be done to support window functions?griffio
04/16/2024, 10:35 AMMateu
04/16/2024, 10:41 AMgriffio
04/16/2024, 11:02 AMSELECT
name,
points,
(SELECT COUNT(*)
FROM highScore hs2
WHERE hs2.points >= hs1.points) AS row_number
FROM highScore hs1
ORDER BY row_number ASC
;
Have play around and see if it matches your expected results 🧪Mateu
04/16/2024, 11:19 AM