I have the following table members
:
album_id | user_id
-------------------
1 1
1 2
1 4
2 1
2 4
4 1
5 3
with a unique constraint on (album_id, user_id)
.
I'd like to get the count of how many users there are per gallery, but only if the gallery contains a given user.
So for instance if I get all rows with user_id = 4
, I'd like to get a result like
album_id | count(user_id)
-------------------------
1 3
2 2