2009/8/22 Stephen Frost <sfr...@snowman.net>:
> Hrmm.  That sounds kinda neat, but you'd still have to specify one of
> the columns in the GROUP BY, I presume?  Or could you just say 'GROUP
> BY' without any columns, and have it GROUP BY the key of the table
> you're using?

You would have to specify the key. I think typically you would have
something like:

SELECT a.*, sum(b.col)
   FROM a,b
 GROUP BY a.pk

Since you have the primary key of a in your group by column you're
allowed to use any columns from a in your select list even if they're
not listed in the group by clause.

The database knows that it can use those values from any output row of
the group since they'll all come from the same orginal row of a. Or
possibly it could use some plan that doesn't involve multiplying that
data in the first place.

-- 
greg
http://mit.edu/~gsstark/resume.pdf

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to