i have a user table, a pro table and a pro_users table to join : user -- many to many --> pro
i want to get the number of users, the number of pro joined to user AND the sum of user+member (this seams not relevant but it's just for testing)
i have this query :
WITH sums AS(
SELECT COUNT(user.user_id) as usercount, COUNT(pro.pro_id) as procount
FROM user
LEFT JOIN pro_users ON user.user_id = pro_users.user_id
LEFT JOIN pro ON pro_users.pro_id = pro.pro_id
)
SELECT usercount, procount, usercount+procount as total FROM sums
the inner select work as expected when queried alone. I've tried to only get members from the outter select and absolutely no result show up and i get
message:Command Executed
in PostgreSql Studio.
desired output:
| usercount | procount | total |
--------------------------------
| 1000 | 500 | 1500 |
What am i mising?
Thanks