From: | Naz Gassiep <naz(at)mira(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Query problem |
Date: | 2007-10-01 10:56:12 |
Message-ID: | 4700D24C.3080301@mira.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Aside from the messy nomenclature, is anyone able to spot why
the "sum" column from the first query is not returning 7, as
the second query suggests that it should? I know that this is
probably simple, and that It's probably going to jump out at
me the minute I hit "Send", but if I don't hit send, then I'll
never see it hehe.
twerl=# SELECT 'contactgroups',
contactgroups.siteid,
contactgroups.id,
contactgroups.name,
contactgroups.description,
SUM(contacts.id),
contactgroups.trashed
FROM contactgroups
LEFT OUTER JOIN contacts ON (contactgroups.id = contacts.groupid)
WHERE contactgroups.trashed IS NOT NULL
AND contactgroups.deleted IS NULL
GROUP BY contactgroups.siteid,
contactgroups.id,
contactgroups.name,
contactgroups.description,
contactgroups.trashed;
?column? | siteid | id | name | description | sum | trashed
---------------+--------+----+--------------------+-------------+-----+-------------------------------
contactgroups | 1 | 3 | Telechoice / Optus | | 594 | 2007-10-01 20:08:51.449825+10
(1 row)
twerl=# select count(*) from contacts where groupid = 3;
count
-------
7
(1 row)
Thanks,
- Naz.
From | Date | Subject | |
---|---|---|---|
Next Message | Ben Trewern | 2007-10-01 11:28:07 | Re: It's time to support GRANT SELECT, UPDATE, ..., ..., ... ON database.* to username |
Previous Message | Magnus Hagander | 2007-10-01 10:32:47 | Re: windows and pg 8.2 (change database to another server) |