Page 1 of 1

Simple SQL Query

PostPosted: Fri Aug 13, 2010 5:31 am
by js2002
Hi,

can u please show me how to make a simple SQL Query that retrieves the stat VPIP?

A friend did this with:

SELECT 100.0 * (sum(holdem_cache.cnt_vpip ))::float/ (sum((case when(holdem_cache.cnt_hands > 0) then holdem_cache.cnt_hands else 1 end)))::float as VPIP FROM holdem_cache WHERE (holdem_cache.id_player = (SELECT id_player from player where player_name = '{0}' AND id_site ='{1}')) GROUP BY holdem_cache.id_player;

But I need it filtered max to the date of the hand. (holdem_hand_player_statistics.date_played)
Theres no date field in the cache right? So how does the builtin Replayer recieve this stat? Directly from the real DB I guess...

I tried some own queries but got stuck:
SELECT (sum((case when(holdem_hand_player_statistics.flg_vpip) then 1 else 0 end))) as cnt_vpip " + "FROM holdem_hand_player_statistics WHERE (id_player = '3054')";

There I failed to get the id for a playername or better: for all playernames that are set up as Hero in PT3.

So I need sth like:

Get the vpip for player <string name> where date_played <= <a date>

Re: Simple SQL Query

PostPosted: Fri Aug 13, 2010 6:39 am
by WhiteRider
The Replayer can't use the cache because it needs to get stats up to a certain date/time, as you're trying to do.
All the queries that PT3 uses are written to the logs so if you view the replayer and then look in the logs you should find the queries that it uses.

Re: Simple SQL Query

PostPosted: Fri Aug 13, 2010 7:30 am
by js2002
thx thx, I got it done.