Different rakeback depending on month/year

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Different rakeback depending on month/year

Postby FabioTheDoc » Tue Dec 27, 2011 2:50 pm

Dear all,

I'm playing around with the custom stats that can be created within PokerTracker. I already have a stat (downloaded from the repository some time ago) which calculates the amount of rakeback generated during every given month. What I'd like to do now is to make this stat "conditional", i.e., to calculate the rakeback differently depending on the date (as my RB deal will change in 2012).

Following the tutorials available on the website I eventually ended up with the following two expressions:

if[date_played_month >= March AND date_played_year = 2011 , sum(tourney_holdem_summary.amt_rake * 0.25) , 0]

sum(if[date_played_year = 2011 AND date_played_month >= March , tourney_holdem_summary.amt_rake * 0.25, 0])

Unfortunately none of them can be validated ("The statement is not valid SQL"). I'm obviously making some stupid mistake, but I don't seem to be able to spot it. Could please anyone give me a hint? :)

Cheers,
Fabio
FabioTheDoc
 
Posts: 9
Joined: Wed May 26, 2010 4:26 pm

Re: Different rakeback depending on month/year

Postby kraada » Tue Dec 27, 2011 3:48 pm

You want:

sum(if[tourney_holdem_results.date_start >= 'March 01 2011'::timestamp, tourney_holdem_summary.amt_rake * .25, 0])
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Different rakeback depending on month/year

Postby FabioTheDoc » Tue Dec 27, 2011 7:16 pm

kraada wrote:You want:

sum(if[tourney_holdem_results.date_start >= 'March 01 2011'::timestamp, tourney_holdem_summary.amt_rake * .25, 0])


Lovely... precisely what I was looking for! Thanks a lot! :)

Just one more thing... what if I'd like to create a "chain" of alternative options (e.g., 25% RB for entire 2011, 30% for January 2012, and so on)?
FabioTheDoc
 
Posts: 9
Joined: Wed May 26, 2010 4:26 pm

Re: Different rakeback depending on month/year

Postby WhiteRider » Wed Dec 28, 2011 4:50 am

Then you would need to "nest" the IF statements, like this:

sum(if[condition1, result1, if[ condition2, result2, if[ ... ] ] ])

The easiest thing will be to start with the newest dates first, so that you don't have to check "between" dates.
So for example:

sum(if[tourney_holdem_results.date_start >= 'January 01 2012'::timestamp, tourney_holdem_summary.amt_rake * .30, if[tourney_holdem_results.date_start >= 'January 01 2011'::timestamp, tourney_holdem_summary.amt_rake * .25, 0]])
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Different rakeback depending on month/year

Postby FabioTheDoc » Wed Dec 28, 2011 8:39 pm

WhiteRider wrote:Then you would need to "nest" the IF statements, like this:

sum(if[condition1, result1, if[ condition2, result2, if[ ... ] ] ])

The easiest thing will be to start with the newest dates first, so that you don't have to check "between" dates.
So for example:

sum(if[tourney_holdem_results.date_start >= 'January 01 2012'::timestamp, tourney_holdem_summary.amt_rake * .30, if[tourney_holdem_results.date_start >= 'January 01 2011'::timestamp, tourney_holdem_summary.amt_rake * .25, 0]])


I love you guys! :heart:
FabioTheDoc
 
Posts: 9
Joined: Wed May 26, 2010 4:26 pm

Re: Different rakeback depending on month/year

Postby FabioTheDoc » Sun Jan 01, 2012 12:08 pm

In case it might be helpful in the future, this is how I've implemented everything.

sum(if[tourney_holdem_results.date_start >= 'March 01 2012'::timestamp AND tourney_holdem_results.date_start <= 'March 31 2012'::timestamp, tourney_holdem_summary.amt_rake * .08, if[tourney_holdem_results.date_start >= 'February 01 2012'::timestamp, tourney_holdem_summary.amt_rake * .1, if[tourney_holdem_results.date_start >= 'January 01 2012'::timestamp, tourney_holdem_summary.amt_rake * .12, if[tourney_holdem_results.date_start >= 'April 01 2011'::timestamp, tourney_holdem_summary.amt_rake * .25, 0]]]])
FabioTheDoc
 
Posts: 9
Joined: Wed May 26, 2010 4:26 pm


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 3 guests