Re-writing a question as the last one was unclear,
I have a database of poker tournament results from which I want to make a profit/loss graph for each player, here is my 2 tables I am working with:
Results Table
ID;PlayerName;TotalBuyIn;Prize;Rebuys;Event;
1;Ole Schemion;100000;1062785;0;Aria $100K July 2014;
2;Isaac Haxton;100000;813394;0;Aria $100K July 2014;
3;Daniel Colman;100000;796821;0;Aria $100K July 2014;
4;Daniel Cates;100000;297000;0;Aria $100K July 2014;
5;Cary Katz;100000;0;0;Alpha 8 Florida 2015;
EventInfo Table
ID;EventName;Date;Location;Country;PokerTour;UniquePlayers;Rebuys;
1;ACOP 500k 2014;2014-11-01;City of Dreams;Macau;APPT;52;50;
2;ACOP Super High Roller 2015;2015-11-13;City of Dreams;Macau;APPT;34;17;
3;Alpha 8 Florida 2013;2013-08-26;Seminole Hard Rock;USA;WPT;18;3;
4;Alpha 8 Florida 2015;2015-01-17;Seminole Hard Rock;USA;WPT;6;0;
5;Aria $100K July 2014;2014-02-14;Emperor Palace;South Africa;WPT;9;1;
In these tables results.event=eventinfo.eventname
To come up with my desired results I want to cumalative sum the difference between 'results.prize' and results.totalbuyin with the sum worked out in eventinfo.date order for every event a particular player has played in. These events should be listed in separate rows, I don't just want one total sum. Here is the query I have tried and the output:
SELECT t1.id,
t1.prize,
t1.TotalBuyIn,
t1.PlayerName,
(SUM(t2.prize)) - (SUM(t2.totalbuyin)),
eventinfo.Date
FROM results t1
INNER JOIN results t2 ON t1.id >= t2.id and t2.PlayerName = "Erik Seidel"
INNER JOIN eventinfo ON t1.Event = eventinfo.EventName
Where t1.PlayerName = "Erik Seidel"
GROUP BY t1.id
ORDER BY eventinfo.Date
Current Output
t1.id;t1.prize;t1.TotalBuyIn;t1.PlayerName;(SUM(t2.prize)) - (SUM(t2.totalbuyin));eventinfo.Date;
1314;618139;98902;Erik Seidel;135685;2011-01-22;
1292;2472555;247255;Erik Seidel;-383552;2011-01-27;
1401;1092780;100000;Erik Seidel;1128465;2011-05-18;
1425;0;100000;Erik Seidel;1028465;2011-12-09;
1127;0;100000;Erik Seidel;-2341985;2012-01-05;
The current output is almost what I want, but the cumulative sum is being worked out in order of results.id instead of eventinfo.date (first line of output, 618139-98902 doesn't equal 135685). Hopefully I have explained this a little more clearly than last time. I am using SQLite3
Aucun commentaire:
Enregistrer un commentaire