I try to create a plot using duckdb wasm.
The select looks like this - and it works in DBeaver:
WITH ranked_data AS (
SELECT
s.DeviceTime,
s.Distance,
a.TPSCode,
RANK() OVER (PARTITION BY s.DeviceTime ORDER BY s.Distance DESC) AS Position
FROM
simpos s
JOIN
athlete a ON a.TPSCode = s.TPSCode
)
SELECT DeviceTime, Distance, TPSCode, Position FROM ranked_data
ORDER BY DeviceTime, Distance DESC;
But in the code i get this error:
async_bindings.ts:150 Uncaught (in promise) Error: Binder Error: Referenced column “Position” not found in FROM clause!
Candidate bindings: “source.Id”
LINE 1: …ESCRIBE SELECT “DeviceTime” AS “col0”, “Position” AS “col1”, “TPSCode” AS "col…
How can i do subqueries or functions ?