Unix Technical Forum

newbie : multiple join produces weird aggregate column results

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 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:49 PM
Greg Lorriman
 
Posts: n/a
Default newbie : multiple join produces weird aggregate column results

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com