PDA

View Full Version : Holecards queries in database



justoagv
02-26-2011, 03:00 PM
Hello,

I'd like to query the db directly in order to get a report similar to the holecards report but for all the players in a given level, rather than only for one player.

I have Holdem Manager v1.11.05 running on PostgresSQL 8.4. For me it is no problem to query HM db directly, I've already done it before, but the problem is that I don't know how to join the holecards table with the results obtained with that hand (%Winning and EV ideally).

Hope you can help me out with this, I will really apreciate it.

Thank you in advance
Kind regards

netsrak
02-27-2011, 08:10 AM
You should find some infos about the database structure in this area: http://forums.holdemmanager.com/custom-reports/

Please come back if you need further help.

justoagv
03-01-2011, 12:09 AM
Hello,

Thank you for your replay, I did find the info that I needed in the custom-reports forum. Here is the query that I'm working with:

SELECT hc.holecardstring,100*SUM(CASE WHEN ph.netamountwon > 0 THEN 1 ELSE 0 END)/COUNT(*) FROM playerhandscashkeycolumns ph,holecards hc where ph.holecardvalue_id = hc.holecard_id and maxstreetseen=4 group by hc.holecardstring;

The goal is to get the total % of win per hand in showdowns for all the players (not only for the hero). The query runs ok, however the results are puzzeling me: All hands seem to win more than 50% on showdown.

I must be making a mistake, but I keep overlooking it, do you see anything unusual in the query?.

Kind regards

netsrak
03-01-2011, 04:38 AM
Sorry, thats beyond my SQL knowledge.

Someone else any idea?

justoagv
03-01-2011, 08:32 PM
Hello,

Sorry, I realized that I was not restricting the results of the query to the pre-flop (all-in) cases, so I was getting the winrates of post-flop hands when players are already commited with these hands (i.e. went to showdown), so the hands had already conected with the board and all had decent winrates.

So including the pre-flop all-in condition this is the final query that I have:

SELECT hc.holecardstring,(100.0*SUM(CSE WHEN ph.netamountwon>0 THEN 1 ELSE 0 END))/(COUNT(*)) winrate FROM playerhandscashkeycolumns ph, holecards hc WHERE ph.holecardsvalue_id=hc.holecard_id and mmaxtreetseen=4 and streetwentallin=0 and group by hc.holecardstring ORDER by winrate DESC;

This query retrieves a custom pre-flop table based in the db records.

Kind regards