{"ok": true, "database": "my_database", "query_name": "team_performance_by_day", "rows": [], "truncated": false, "columns": ["team", "game_date", "wins", "losses", "otl", "sol", "games_played", "points"], "query": {"sql": "with data as (\n    select ht.name as home_team\n    , at.name as away_team\n    , g.game_date\n    , g.home_team_score\n    , g.away_team_score\n    , g.game_status\n    , case\n        when ht.name = :team and g.home_team_score > g.away_team_score then 1\n        when at.name = :team and g.home_team_score < g.away_team_score then 1\n        else 0\n    end as 'W'\n    , case\n        when ht.name = :team and g.game_status = 'Final' and g.home_team_score < g.away_team_score then 1\n        when at.name = :team and g.game_status = 'Final' and g.home_team_score > g.away_team_score then 1\n        else 0\n    end as 'L'\n    , case\n        when ht.name = :team and (g.game_status = 'Final OT' and g.game_status != 'Final SO') and g.home_team_score < g.away_team_score then 1\n        when at.name = :team and (g.game_status = 'Final OT' and g.game_status != 'Final SO') and g.home_team_score > g.away_team_score then 1\n        else 0\n    end as 'OTL'\n    , case\n        when ht.name = :team and g.game_status = 'Final SO' and g.home_team_score < g.away_team_score then 1\n        when at.name = :team and g.game_status = 'Final SO' and g.home_team_score > g.away_team_score then 1\n        else 0\n    end as 'SOL'\nfrom gamedata g\nleft join team ht on g.home_team_id = ht.team_id\nleft join team at on g.away_team_id = at.team_id\nwhere (ht.name = :team or at.name = :team)\nand g.season_id = :season_id)\n\nselect\n    :team as team,\n    game_date,\n    SUM(W) OVER (ORDER BY game_date) as wins,\n    SUM(L) OVER (ORDER BY game_date) as losses,\n    SUM(OTL) OVER (ORDER BY game_date) as otl,\n    SUM(SOL) OVER (ORDER BY game_date) as sol,\n    SUM(W + L + OTL + SOL) OVER (ORDER BY game_date) as games_played,\n    SUM(W * 2 + OTL + SOL) OVER (ORDER BY game_date) as points\nfrom data\norder by game_date;", "params": {"team": "", "season_id": ""}}, "error": null, "private": false, "allow_execute_sql": true, "query_ms": 3.147834911942482}