lundi 10 août 2015

SQLite - Get Winner of Each Game (Rank Over Partition )

I'm creating a score tracking app for Carcassonne. I'd like to get the Winner of each game.

I've got this working in MS-SQL and now I'm trying to convert the db to SQLite.

Schema
http://ift.tt/1WdhpSS

MS-SQL

CREATE VIEW vTopScorePerGame AS
WITH ranked AS (
    SELECT      RANK() OVER (PARTITION BY [GameID] ORDER BY TotalScore DESC) AS Position,
                   PlayerID,
                PlayerName, 
                TotalScore,
                [GameID]
    FROM        vScore
)
SELECT      [GameID],
            PlayerID,
            PlayerName AS Winner,
            TotalScore
FROM        ranked      
WHERE       ranked.Position = 1

When I'm trying in SQLFiddle or SQLiteBrowser I'm getting the following error:

near "(": syntax error:

Can someone point me in the right direction?


Functions
WITH
http://ift.tt/19DQXh0
COALESCE
http://ift.tt/1zoPQdb

Unsupported
http://ift.tt/1IzWGSg

Aucun commentaire:

Enregistrer un commentaire