Page 1 of 1

syntax count number of hands in DB PGadmin4 PSQL

PostPosted: Tue Oct 25, 2022 5:06 am
by ommaha
Hi,

I am not sure if this is the right spot to ask here but I try to count the number of hands in pg admin.
This is a working script that shows me if I played at least one hand in the last 3 minutes. It returns a 0 or 1. How can I change that to show me the number of hands that I played in the last 3 minutes instead? Any help would be very appreciated

SELECT
CASE
WHEN (EXISTS ( SELECT 1
FROM cash_hand_player_statistics, player, player player_real
WHERE player.id_player = cash_hand_player_statistics.id_player
AND player_real.id_player = cash_hand_player_statistics.id_player_real
AND (cash_hand_player_statistics.id_player IN ( SELECT player_1.id_player
FROM player player_1
WHERE player_1.player_name_search = 'xxxxx'::text AND player_1.id_site = '100'::smallint
UNION
SELECT player_1.id_player
FROM player player_1
WHERE player_1.id_player_alias <> '0'::smallint))
AND cash_hand_player_statistics.id_gametype <> 1
AND cash_hand_player_statistics.date_played >= (timezone('UTC'::text, now()) - '00:03:00'::interval)
AND cash_hand_player_statistics.date_played <= timezone('UTC'::text, now())
GROUP BY cash_hand_player_statistics.id_player, player.player_name)) THEN 1
ELSE 0
END AS "case";

Re: syntax count number of hands in DB PGadmin4 PSQL

PostPosted: Tue Oct 25, 2022 5:35 am
by Flag_Hippo
Unfortunately that's something beyond my own knowledge but if a more advanced PostgreSQL user sees this they may be able to offer some advice.

Re: syntax count number of hands in DB PGadmin4 PSQL

PostPosted: Wed Oct 26, 2022 3:13 am
by WhiteRider
It's beyond my PostgreSQL knowledge too, but maybe you can replace "SELECT 1 FROM" with "SELECT COUNT FROM"?

Re: syntax count number of hands in DB PGadmin4 PostgreSQL

PostPosted: Thu Oct 27, 2022 9:27 am
by ommaha
Thank you very much. It creates an error message unfortunately

highfalutin