S
S
sl02021-12-23 14:37:59
PostgreSQL
sl0, 2021-12-23 14:37:59

How to get the number of users with 2 claims?

The question is simple, but I've been stupid for a long time.
There is a table of requests: id, user_id, event_id. I need to get the number of users who have applications for 2 different events at the same time. Those. need something like
count(user_id) ... where event_id in (1,2)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-12-23
@sl0

select count(*) from (select user_id from events group by user_id having count(event_id) >= 2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question