MySQL Forums
Forum List  »  General

Postgres Query Total login per user a day per database
Posted by: ravi kumar
Date: June 08, 2023 10:36PM

I'm trying to write a query that gives me total logins per user, per day and group by user_ID

I have an events.action table that show logins, created_at TIMESTAMP

Any suggestions

I tried to do a subquery count and I found this query on Stackoverflow, but I couldn't get it work in my favor.

select userid, count(distinct date_trunc('day', datetime)) as countLogins from events where action = 'login' Group by userId;

Options: ReplyQuote


Subject
Written By
Posted
Postgres Query Total login per user a day per database
June 08, 2023 10:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.