I started delving into the database itself via pgAdmin, and wondered whether your following query is even correct.
kraada wrote:log( 1 + if[id_tourney_type in (SELECT id_tourney_type from tourney_table_type where tourney_table_type.val_flags SIMILAR TO '%(D|F)%'), 2, cnt_players])
Shouldn't "id_tourney_type" (2x) be "id_table_type" ? The way I understand this query is that the SELECT takes the primary key from all records from table tourney_table_type that have the D or F flag in val_flags, and then checks whether 'this' tourney has a foreign key id_table_type in that result set.
I'm actually surprised that PT4 even takes your query, because table tourney_table_type doesn't even have a column id_tourney_type.
That being said, I tried to start from scratch again to better understand the stats behavior. So I wanted to create a simple custom Stat that gives the 'equivalent' players. This is basically just the regular number of players of a tournament, except that for DON or F50 this value should be 2. I ended up with this stat :
if[id_table_type in (SELECT id_table_type from tourney_table_type where tourney_table_type.val_flags SIMILAR TO '%(D|F)%'), 2, cnt_players]
Now, thing is that if I don't check the Group By checkbox, I again get the SQL Error when I add that stat to one of the default reports (I use the Tournament - Basic - By Tournament one, and added my Equivalent Players stat after the default Players stat).
If I do tick the GROUP BY checkbox, my results are wrong as the column will always give value 2.