Re: [GENERAL] Why does aggregate query allow select of non-group by or aggregate values?

2011-12-10 Thread Jack Christensen
On 12/9/2011 4:57 PM, David Johnston wrote: Functions are evaluated once for each row that it generated by the surrounding query. This is particularly useful if the function in question takes an aggregate as an input: SELECT col1, array_processing_function( ARRAY_AGG( col2 ) ) FROM table

[GENERAL] Why does aggregate query allow select of non-group by or aggregate values?

2011-12-09 Thread Jack Christensen
CREATE TABLE people( id serial PRIMARY KEY, name varchar NOT NULL ); INSERT INTO people(name) VALUES('Adam'), ('Adam'), ('Adam'), ('Bill'), ('Sam'), ('Joe'), ('Joe'); SELECT name, count(*), random() FROM people GROUP BY name; I would expect this query to cause an error because of

Re: [GENERAL] Why does aggregate query allow select of non-group by or aggregate values?

2011-12-09 Thread Henry Drexler
On Fri, Dec 9, 2011 at 5:48 PM, Jack Christensen ja...@hylesanderson.eduwrote: CREATE TABLE people( id serial PRIMARY KEY, name varchar NOT NULL ); INSERT INTO people(name) VALUES('Adam'), ('Adam'), ('Adam'), ('Bill'), ('Sam'), ('Joe'), ('Joe'); SELECT name, count(*), random() FROM

Re: [GENERAL] Why does aggregate query allow select of non-group by or aggregate values?

2011-12-09 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Jack Christensen Sent: Friday, December 09, 2011 5:48 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Why does aggregate query allow select of non-group

Re: [GENERAL] Why does aggregate query allow select of non-group by or aggregate values?

2011-12-09 Thread Adrian Klaver
On 12/09/2011 02:48 PM, Jack Christensen wrote: CREATE TABLE people( id serial PRIMARY KEY, name varchar NOT NULL ); INSERT INTO people(name) VALUES('Adam'), ('Adam'), ('Adam'), ('Bill'), ('Sam'), ('Joe'), ('Joe'); SELECT name, count(*), random() FROM people GROUP BY name; I would expect