Re: GROUP BY ALL

2023-01-06 Thread Andrey Borodin
On Fri, Jan 6, 2023 at 1:56 PM Bruce Momjian wrote: > Because Postgres requires GROUP BY > of all non-aggregate columns of a target list, Postgres could certainly > automatically generate the GROUP BY. However, readers of the query > might not easily distinguish function calls from aggregates, so

Re: GROUP BY ALL

2023-01-06 Thread Bruce Momjian
On Mon, Dec 19, 2022 at 05:53:46PM +0100, Vik Fearing wrote: > I think this is a pretty terrible idea. If we want that kind of behavior, > we should just allow the GROUP BY to be omitted since without grouping sets, > it is kind of redundant anyway. > > I don't know what my opinion is on that. T

Re: GROUP BY ALL

2022-12-19 Thread Vik Fearing
On 12/19/22 05:19, Andrey Borodin wrote: Hi hackers! I saw a thread in a social network[0] about GROUP BY ALL. The idea seems useful. I always was writing something like select datname, usename, count(*) from pg_stat_activity group by 1,2; and then rewriting to select datname, usename,

Re: GROUP BY ALL

2022-12-19 Thread Isaac Morland
On Sun, 18 Dec 2022 at 23:30, Tom Lane wrote: > Andrey Borodin writes: > > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. > > Isn't that just a nonstandard spelling of SELECT DISTINCT? > In a pure relational system, yes; but since Postgres allows duplicate ro

Re: GROUP BY ALL

2022-12-18 Thread David G. Johnston
On Sunday, December 18, 2022, Tom Lane wrote: > Andrey Borodin writes: > > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. > > Isn't that just a nonstandard spelling of SELECT DISTINCT? > > What would happen if there are aggregate functions in the tlist? > I'm

Re: GROUP BY ALL

2022-12-18 Thread Andrey Borodin
On Sun, Dec 18, 2022 at 8:30 PM Tom Lane wrote: > > I'm not especially on board with "ALL" meaning "ALL (oh, but not > aggregates)". Yes, that's the weak part of the proposal. I even thought about renaming it to "GROUP BY SOMEHOW" or even "GROUP BY SURPRISE ME". I mean I see some cases when it's

Re: GROUP BY ALL

2022-12-18 Thread Tom Lane
Andrey Borodin writes: > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. Isn't that just a nonstandard spelling of SELECT DISTINCT? What would happen if there are aggregate functions in the tlist? I'm not especially on board with "ALL" meaning "ALL (oh, but no