Open Side Menu Go to the Top

12-30-2007 , 12:40 PM
Hello all,

I am trying to construct a query which calculates my rakeback earned so far. My player id is 8 and I get 30% rakeback. Let me start with to say that I am pretty new to SQL. I read a few tutorials today and this is what I came up with.

My query is based on the following rakeback method: "Contributed - Rake per person is total rake in hand divided by number of players who contributed to the pot."

The following query selects for each game the numer of players who contributed to the pot:

Code:
                SELECT          game_id                 AS game_id,
                                COUNT(player_id)        AS nr_of_players_who_contributed_to_pot
                FROM            game_players
                WHERE           total_bet > 0
                GROUP BY        game_id
Our next query selects all games I played in which the rake greater than 0:

Code:
                SELECT          game_players.game_id    AS game_id,
                                game.rake               AS rake
                FROM            game_players            AS game_players,
                                game                    AS game
                WHERE           game_players.player_id = 8 		AND
                                game.game_id = game_players.game_id 	AND
                                game.rake > 0
So if we combine both queries, I can calcuate my rake and rakeback:

Code:
SELECT 	total_rake_paid, total_rake_paid * 0.30
FROM
(
        SELECT	SUM(rake / nr_of_players_who_contributed_to_pot) AS total_rake_paid
        FROM
        (
                SELECT          game_players.game_id    AS game_id,
                                game.rake               AS rake
                FROM            game_players            AS game_players,
                                game                    AS game
                WHERE           game_players.player_id = 8 		AND
                                game.game_id = game_players.game_id 	AND
                                game.rake > 0
        ) t1,
        (
                SELECT          game_id                 AS game_id,
                                COUNT(player_id)        AS nr_of_players_who_contributed_to_pot
                FROM            game_players
                WHERE           total_bet > 0
                GROUP BY        game_id
        ) t2
        WHERE   t1.game_id = t2.game_id
) t
What do you guys think? As said, I'm pretty new to all this stuff, so can please someone confirm this query is correct.

FWIW, I have about 4700 hands in my database (100NL UB), my query says that I have paid $841 rake, which equals to $252 rakeback.

Thank you very much!
SQL query for rakeback Quote
SQL query for rakeback
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
SQL query for rakeback
12-31-2007 , 02:29 PM
Is this a boring question?
SQL query for rakeback Quote
12-31-2007 , 07:19 PM
pokertracker/pokeroffice isn't accurate when figuring out rakeback

the rake site you signed up with you update it daily and tell you how much you have earned
SQL query for rakeback Quote
01-01-2008 , 07:02 AM
I know, that's why I am creating my own query. Or what do you mean?

I don't have RB yet, I just want to have a good estimate.
SQL query for rakeback Quote
SQL query for rakeback
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
SQL query for rakeback

      
m