Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Count number of events per user

i have table similar to this:

ID | event | user | time | note | archived

I need the number of events that individual users have been to, but one user can have more than one record for one event, so I only need to count it once.

The result should look like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

user | nrofevents

Thank you for any advice.

>Solution :

Possibly it’s just the use of distinct you need?

select user, count(distinct event) as nrofevents
from t
group by user;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading