Add a previous row value of another column grouped by same column (soccer data)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Add a previous row value of another column grouped by same column (soccer data)



Data


Country League Season Month monthDay weekDay Time HomeTeam AwayTeam FTHG FTAG FTR HomeTeamPoints AwayTeamPoints
Denmark Superliga 2015/2016 July 19 Sunday 12:30:00 Odense Hobro 3 0 H 3 0
Denmark Superliga 2015/2016 July 24 Friday 17:00:00 Hobro Aalborg 0 1 A 0 3
Denmark Superliga 2015/2016 August 2 Sunday 17:00:00 Brondby Hobro 0 2 A 0 3
Denmark Superliga 2015/2016 August 8 Saturday 15:00:00 Hobro Viborg 1 1 D 1 0
Denmark Superliga 2015/2016 August 17 Monday 18:00:00 Sonderjyske Hobro 3 0 H 0 3
Denmark Superliga 2015/2016 August 21 Friday 17:30:00 Hobro Nordsjaelland 1 3 A 1 1
Denmark Superliga 2015/2016 August 30 Sunday 19:30:00 Midtjylland Hobro 2 0 H 7 3



Desired output:


Country League Season Month monthDay weekDay Time HomeTeam AwayTeam FTHG FTAG FTR HomeTeamPoints AwayTeamPoints HomeTeamTotalPoints AwayTeamTotalPoints
Denmark Superliga 2015/2016 July 19 Sunday 12:30:00 Odense Hobro 3 0 H 3 0 0
Denmark Superliga 2015/2016 July 24 Friday 17:00:00 Hobro Aalborg 0 1 A 0 3 0
Denmark Superliga 2015/2016 August 2 Sunday 17:00:00 Brondby Hobro 0 2 A 0 3 3
Denmark Superliga 2015/2016 August 8 Saturday 15:00:00 Hobro Viborg 1 1 D 1 0 4
Denmark Superliga 2015/2016 August 17 Monday 18:00:00 Sonderjyske Hobro 3 0 H 0 3 4
Denmark Superliga 2015/2016 August 21 Friday 17:30:00 Hobro Nordsjaelland 1 3 A 1 1 4
Denmark Superliga 2015/2016 August 30 Sunday 19:30:00 Midtjylland Hobro 2 0 H 7 3 4



Note: In the previous example only games relationated to Hobro team are showed.



My problem is when I want to add total points per team. In a match (row) I have HomeTeamPoints and AwayTeamPoints. I can not find the way I can group by HomeTeam and add the points from the last time that team was AwayTeam(and vice versa).



I have managed to get total points by creating two tables and filtering by team name. This gives me the current classification of the League but it does not help me to put in a database where there are more seasons.



My goal is that the total points are updated every week grouping by season and team and work for past seasons.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard