Simple SQL Query

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

Simple SQL Query

Postby js2002 » 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>
js2002
 
Posts: 1501
Joined: Fri Feb 15, 2008 5:44 am
Location: Germany

Re: Simple SQL Query

Postby WhiteRider » Fri Aug 13, 2010 6:39 am

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.
WhiteRider
Moderator
 
Posts: 54017
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Simple SQL Query

Postby js2002 » Fri Aug 13, 2010 7:30 am

thx thx, I got it done.
js2002
 
Posts: 1501
Joined: Fri Feb 15, 2008 5:44 am
Location: Germany


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 36 guests

cron