- Code: Select all
holdem_hand_player_detail.id_hand = holdem_hand_player_statistics.id_hand
The (almost) full SQL is quoted bellow for reference (I removed most of the columns for clarity):
- Code: Select all
SELECT (holdem_hand_player_statistics.id_limit) ,
(COUNT(holdem_hand_player_statistics.id_hand)),
(SUM(holdem_hand_player_statistics.amt_won)) ,
irrelevant columns removed...
FROM holdem_hand_player_detail,
holdem_hand_player_statistics
WHERE (holdem_hand_player_statistics.id_player = 2)
AND (((holdem_hand_player_detail.flg_f_open))
AND ((holdem_hand_player_statistics.date_played >= '2008/04/19 11:00'
AND holdem_hand_player_statistics.date_played <= '2008/04/20 10:59'))
AND ((holdem_hand_player_statistics.id_holecard IN (1))))
GROUP BY (holdem_hand_player_statistics.id_limit)
Adding the join condition fixes it.
P.S.
If you run this on your system, make sure you either run it on a small DB or give very strict filters. I had to kill postgres on my machine because I ran it without any other filters on my full database and the would not complete.