[HN Gopher] Waiting for SQL:202y: Group by All
___________________________________________________________________
Waiting for SQL:202y: Group by All
Author : ingve
Score : 33 points
Date : 2025-11-11 09:08 UTC (5 days ago)
(HTM) web link (peter.eisentraut.org)
(TXT) w3m dump (peter.eisentraut.org)
| Exuma wrote:
| Also just let me reference the damn alias in a group by, FUCK
| mberning wrote:
| Some do. It would also be nice to reference by ordinal number
| similar to order by. Very handy for quick and dirty queries. I
| can see the issue though that people start to lean on it too
| much.
| sbuttgereit wrote:
| At least in PostgreSQL, both by alias and ordinal are possible:
| localhost(from SCB-MUSE-BOXX).postgres.scb.5432 [Sun Nov 16
| 12:02:15 PST 2025] > create table test (a_key integer
| primary key, a_group integer, a_val numeric); CREATE
| TABLE Time: 3.102 ms localhost(from SCB-MUSE-
| BOXX).postgres.scb.5432 [Sun Nov 16 12:02:25 PST 2025] >
| insert into test (a_key, a_group, a_val) values (1, 1, 5.5),
| (2, 1, 2.6), (3, 2, 1.1), (4, 2, 6.5); INSERT 0 4
| Time: 2.302 ms localhost(from SCB-MUSE-
| BOXX).postgres.scb.5432 [Sun Nov 16 12:02:58 PST 2025] >
| select a_group AS my_group, sum(a_val) from test group by
| my_group; my_group | sum ----------+-----
| 2 | 7.6 1 | 8.1 (2 rows) Time:
| 4.124 ms localhost(from SCB-MUSE-BOXX).postgres.scb.5432
| [Sun Nov 16 12:03:15 PST 2025] > select a_group AS
| my_group, sum(a_val) from test group by 1; my_group |
| sum ----------+----- 2 | 7.6
| 1 | 8.1 (2 rows) Time: 0.360 ms
| kermatt wrote:
| PostgreSQL and DuckDB support this, which makes MSSQL feel like
| a dinosaur in context.
| zX41ZdbW wrote:
| I think it should be not only in GROUP BY, but in every
| context, e.g., inside expressions in SELECT, WHERE, etc.
| elygre wrote:
| Let me reference fields as I create them: select
| xxxxx as a , a * 2 as b
| zX41ZdbW wrote:
| This will be great! One of the things ClickHouse has had since
| 2016.
| dorianmariecom wrote:
| would be nice
| cm2187 wrote:
| Snowflake has that, once you start using it, it's painful to go
| back.
| elchief wrote:
| duckdb has it
|
| https://duckdb.org/docs/stable/sql/query_syntax/groupby
| oulipo2 wrote:
| Not directly related, but I saw this project recently of a data
| language by google which is quite cool
| https://www.malloydata.dev/
| chewxy wrote:
| BigQuery has that and I've been loving using it since they
| introduced it
___________________________________________________________________
(page generated 2025-11-16 23:00 UTC)