SQL SELECT/GROUP BY Syntax

Discussions center on SQL query syntax improvements, including flexible SELECT and GROUP BY behaviors, automatic grouping of non-aggregated columns, FROM-first syntax, and features in databases like DuckDB, Postgres, and PRQL.

📉 Falling 0.3x Databases
3,497
Comments
20
Years Active
5
Top Authors
#4786
Topic ID

Activity Over Time

2007
8
2008
4
2009
26
2010
53
2011
51
2012
63
2013
163
2014
112
2015
144
2016
165
2017
139
2018
210
2019
238
2020
275
2021
352
2022
447
2023
429
2024
310
2025
302
2026
6

Keywords

e.g REPL HAVING SQL DSL IS SUM RDBMS PK ORDER select sql query sum group clause columns organisation row window

Sample Comments

hackernewds • Mar 20, 2022 • View on HN

Absolutely cannot wait for this to come to SQL. Or is there a way already to adopt this?

frogulis • Jun 17, 2023 • View on HN

Go further: `FROM users WHERE name LIKE 'a%' SELECT name, id, location` - after all, you can WHERE on things that aren't projected by SELECT

mritchie712 • Nov 11, 2022 • View on HN

why would you do all this work when postgres sorted this all out over a decade ago?

icambron • Dec 31, 2021 • View on HN

Some DBs let you do this and it's helpful when one of the things you're selecting is some complex scalar expression, but you still have to list each item in the group by

int_19h • Jun 28, 2022 • View on HN

Because of things like WHERE/HAVING in SQL.

nerder92 • Oct 28, 2019 • View on HN

Wow, i'm struggling with a sql query in psql just right now, this seems to be just what i was looking for! Thank you so much!

nerdponx • Nov 3, 2016 • View on HN

I like the "WHERE 1" trick, thanks!

joshmn • Apr 20, 2020 • View on HN

Don't get ahead of yourself: it's SELECT with GROUP BY.

robinLord • Apr 23, 2023 • View on HN

Yea sorry, unfortunately not something the SQL library I used supports, select * is the best for now but I'm adding "table preview" to the list for future updates!

revskill • Jun 17, 2023 • View on HN

How about nested selection ? SQL is dump because it doesn't allow nested selection by default.