You're right, thanks! I just had to do a little adjustment on the lateral join. Since both users and events have user_id and user_group, PostgreSQL complains that I can't have more than one column with the same name. I fixed it by changing the LATERAL condition from "ON TRUE" to "USING (user_id,user_group)" (which I didn't even knew I could do). |