Simple SQL Query
Posted: Fri Aug 13, 2010 5:31 am
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>
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>