syntax count number of hands in DB PGadmin4 PSQL

Discuss how to create custom stats, reports and HUD profiles and share your creations.

Moderators: WhiteRider, kraada, Flag_Hippo, morny, Moderators

syntax count number of hands in DB PGadmin4 PSQL

Postby ommaha » Tue Oct 25, 2022 5:06 am

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";
ommaha
 
Posts: 218
Joined: Sun Jul 29, 2012 8:46 am

Re: syntax count number of hands in DB PGadmin4 PSQL

Postby Flag_Hippo » Tue Oct 25, 2022 5:35 am

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.
Flag_Hippo
Moderator
 
Posts: 14441
Joined: Tue Jan 31, 2012 7:50 am

Re: syntax count number of hands in DB PGadmin4 PSQL

Postby WhiteRider » Wed Oct 26, 2022 3:13 am

It's beyond my PostgreSQL knowledge too, but maybe you can replace "SELECT 1 FROM" with "SELECT COUNT FROM"?
WhiteRider
Moderator
 
Posts: 53961
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: syntax count number of hands in DB PGadmin4 PostgreSQL

Postby ommaha » Thu Oct 27, 2022 9:27 am

Thank you very much. It creates an error message unfortunately
ommaha
 
Posts: 218
Joined: Sun Jul 29, 2012 8:46 am


Return to Custom Stats, Reports and HUD Profiles

Who is online

Users browsing this forum: No registered users and 30 guests

cron