This is a discussion on newbie : multiple join produces weird aggregate column results within the pgsql Sql forums, part of the PostgreSQL category; --> Hello, I'm joining on two tables and in order to get some totals. I get the correct 'count' for ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, I'm joining on two tables and in order to get some totals. I get the correct 'count' for count(pr.person_id), but count(ig.person_id) is the same number!!!! but should be significantly less. There doesn;t seem to be any docs on multiple joins and goggle- groups is barely usable for searching any longer. Anyone know where I'm going wrong? : SELECT login_from_users, pe.created_on, count(pr.person_id) as presents_count, count(ig.person_id) as groups , CASE WHEN private_lists='t' THEN 'private' ELSE '' END as status FROM people pe LEFT JOIN presents pr on pe.id=pr.person_id LEFT JOIN items_groups ig on pe.id=ig.person_id GROUP BY pr.person_id, login_from_users, pe.created_on, pe.private_lists, ig.person_id ORDER BY pe.created_on |