bengele
07-29-2005, 01:33 PM
I have always wondered how long it takes me to finish/bust out of a tourney so I finally broke down and wrote a SQL query to figure it out and thought I would share.
First you need to find your player ids by running this query
select * from players where screen_name = 'username'
Then you can execute this query
select sum(time) / count(*) as avg_time, count(*) as count from
(select ga.tourney_id, min(ga.date_played), max(ga.date_played), age(max(ga.date_played), min(ga.date_played)) as time from
tourney_game_players as pl join tourney_game as ga on pl.tourney_id = ga.tourney_id and pl.game_id = ga.game_id
join tourney as trny on ga.tourney_id = trny.tourney_id
where pl.player_id in (ids) and trny.buy_in = amount and table_type = 1 group by ga.tourney_id) as qry
by putting your ids in the id field (put them in as a comma separated list) and set the buy in level. If you want to run it for all buy in levels either remove the buy in condition or change it to trny.buy_in > 0
I think this will only work for the postgres database because Access doesn't have the age function. I could be wrong however. You can execute the query by going to Start -> Programs -> PostgresSQL 8.0 -> pgAdmin III and then select the database and choose Tools -> Connect enter your password and the choose Tools -> Query Tool. After you have entered the query use Query -> Execute to run it.
I have lasted about 36 minutes over ~400 tourneys. I would be interested as to what other are averaging.
Also if any one finds a bug in my qurey (you know like a decimal point out of position) could you let me know.
First you need to find your player ids by running this query
select * from players where screen_name = 'username'
Then you can execute this query
select sum(time) / count(*) as avg_time, count(*) as count from
(select ga.tourney_id, min(ga.date_played), max(ga.date_played), age(max(ga.date_played), min(ga.date_played)) as time from
tourney_game_players as pl join tourney_game as ga on pl.tourney_id = ga.tourney_id and pl.game_id = ga.game_id
join tourney as trny on ga.tourney_id = trny.tourney_id
where pl.player_id in (ids) and trny.buy_in = amount and table_type = 1 group by ga.tourney_id) as qry
by putting your ids in the id field (put them in as a comma separated list) and set the buy in level. If you want to run it for all buy in levels either remove the buy in condition or change it to trny.buy_in > 0
I think this will only work for the postgres database because Access doesn't have the age function. I could be wrong however. You can execute the query by going to Start -> Programs -> PostgresSQL 8.0 -> pgAdmin III and then select the database and choose Tools -> Connect enter your password and the choose Tools -> Query Tool. After you have entered the query use Query -> Execute to run it.
I have lasted about 36 minutes over ~400 tourneys. I would be interested as to what other are averaging.
Also if any one finds a bug in my qurey (you know like a decimal point out of position) could you let me know.