SQL Query's question flg vs cnt

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

SQL Query's question flg vs cnt

Postby mrstennis » Fri Jun 04, 2010 4:34 pm

I am bit surprised about the flg and cnt symbols.

The manual says that flg only can be 0 or 1, true or false.

However I made this query for the 3bet preflop%:

Code: Select all
/* PT3 RING  query to get 3bet % */
"SELECT (case when (count(*)!=0) \
                 then   (cast(sum(case when flg_p_3bet then 1 else 0 end) as real) \
                     / cast(sum(case when flg_p_3bet_opp then 1 else 0 end) as real)) \
           else (-1) \
       end) as result \
FROM   player as P, holdem_hand_player_statistics as S \
WHERE  S.id_player = P.id_player AND \
      P.player_name like '%SCREENNAME%' AND \
      P.id_site='%SITEID%'",


When I retreive the value for this symbol it returns 0.21, which is the same value that PT3 gives me in the Position Tab where I added 3bet PF only there it is 21 as the expression is:
(cnt_p_3bet / cnt_p_3bet_opp) * 100

While in fact I should have to use cnt_p_3bet and cnt_p_3bet_opp. But when I use it with cnt the value returns -1.

How is this possible as when it says flg can only be 0 or 1, then it should be like 0 divided by 1 = -1 or 1 divided by 0 = -1 or 0 as well. I really dont get this and soon I want to add custom stats in PT3 in the way you explained me before (which worked perfectly btw and thanks for that).


I am afraid that when I make my custom stats for each position (bb or sb) that it will go wrong as I cant find any flg_p_3bet in the configure stats menu.
mrstennis
 
Posts: 20
Joined: Mon May 24, 2010 2:22 pm

Re: SQL Query's question flg vs cnt

Postby kraada » Fri Jun 04, 2010 5:36 pm

I think you're a bit confused by the difference between columns in PT3's custom statistics section and columns in the PT3 database.

The flags in the PT3 database only have values of 0 or 1. The columns in the Configure Statistics section are defined by reference to database elements but are not themselves in the database in any way. So cnt_p_3bet is defined as a column and it's the count of how many times a player 3 bet preflop. These columns can then be used in Statistics (on the Stats tab) which can display in the main PT3 window (or the HUD, so long as they're in the Player Statistics section). But the columns themselves aren't ever actually added to the database.

For a complete list of data that's stored in the database, see the Database Schema on our documentation page.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: SQL Query's question flg vs cnt

Postby mrstennis » Fri Jun 04, 2010 6:12 pm

Alright that clarify's a bit but not completely. I retreive the colums from the database.

But then still, how can this ever be 0.21, if flg functions will only contain a 0 or a 1. And why doesn't it work when I change it to (cnt_p_3bet / cnt_p_3bet_opp) = -1

(flg_p_3bet / flg_p_3bet_opp) = 0.21

I use my own hud and this is what it returns, which matches my preflop 3bet% exactly when I look it up in the position tab.

Btw I must honestly admit that I dont really understand how this query ever can work as it's like (flg_p_3bet / \ flg_p_3bet_opp) guess the \ means end of line or something, but it does work.

I'm trying to make a similar query with donkbet flop but there I can't get it too work, not with cnt and not with flg
mrstennis
 
Posts: 20
Joined: Mon May 24, 2010 2:22 pm

Re: SQL Query's question flg vs cnt

Postby mrstennis » Fri Jun 04, 2010 6:30 pm

I am btw looking in the database symbol list and Ican find flg_t_donk and flg_r_donk, is there no flg_f_donk at all?
mrstennis
 
Posts: 20
Joined: Mon May 24, 2010 2:22 pm

Re: SQL Query's question flg vs cnt

Postby kraada » Sat Jun 05, 2010 8:34 am

There are no donk or float flop flags in the database, those columns are built differently.

Let me go over one simple column definition and maybe that will clear things up. We're looking at 3Bet Preflop. Go to Configure --> Configure Statistics --> Holdem Cash Player Statistics Section --> Stats tab. Click on 3Bet Preflop. You can see the value expression there reads:
(cnt_p_3bet / cnt_p_3bet_opp) * 100. Go to the Columns tab. Click on cnt_p_3bet. This is the definition for cnt_p_3bet. cnt_p_3bet is not not a database element directly. The definition reads: sum(if[holdem_hand_player_statistics.flg_p_3bet, 1, 0]).

The sum() part adds up a bunch of times. What times? Based on the result of the if[] statement. When flg_p_3bet is true, it adds 1. When flg_p_3bet is false, it adds 0. The result is you get a count (cnt) of the number of times you 3bet preflop. (All columns in the Player Statistics section go through all hands one by one.)

Similarly, cnt_p_3bet_opp is the count of how many times a player had a chance to 3-bet preflop.

When you put the number of times you actually 3bet over the number of times you could have 3bet and you multiply by 100 you get the percentage of the time you 3bet given the opportunity to do so.

The flags are used to build the counts and the counts are used to build the statistics. But the only thing in the database itself are the flags.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY


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

Who is online

Users browsing this forum: No registered users and 0 guests