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

Поиск
Список
Период
Сортировка
От Jack Christensen
Тема Why does aggregate query allow select of non-group by or aggregate values?
Дата
Msg-id 4EE29020.2010603@hylesanderson.edu
обсуждение исходный текст
Ответы Re: Why does aggregate query allow select of non-group by or aggregate values?  (Henry Drexler <alonup8tb@gmail.com>)
Re: Why does aggregate query allow select of non-group by or aggregate values?  ("David Johnston" <polobo@yahoo.com>)
Re: Why does aggregate query allow select of non-group by or aggregate values?  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-general
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 random(). I ran
into this using an array produced by a subquery as a column in the
select of an aggregate query, but I was able to boil it down to this
contrived example. Shouldn't any expression that is not in the group by
or an aggregate function be rejected?

What am I not understanding?

Thanks.

--
Jack Christensen
jackc@hylesanderson.edu


В списке pgsql-general по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Is the a "magic number" for WAL files
Следующее
От: Henry Drexler
Дата:
Сообщение: Re: Why does aggregate query allow select of non-group by or aggregate values?