3 ms·
I’m not sure the sub query would be necessary if the weird ast-based naming didn’t exist. Couldn’t you just write: SELECT a+1 AS a1 FROM t GROUP BY a1 ?
by dan-robertson 7y ago
I’m not sure the sub query would be necessary if the weird ast-based naming didn’t exist. Couldn’t you just write:
SELECT a+1 AS a1 FROM t GROUP BY a1
?
- benesch 7y agoYou can do that in PostgreSQL, but not according to the spec, apparently, and the PostgreSQL developers regret the feature. [0] (As someone who's spent a lot of time trying to simulate PostgreSQL's name resolution rules... it's reassuring to know that the rules are painful inside of PostgreSQL too.) [0]: https://www.postgresql.org/message-id/7608.1259177709%40sss.pgh.pa.us https://www.postgresql.org/message-id/7608.1259177709%40sss....
- jamii 7y agoI never figured out why AS isn't allowed in the GROUP BY clause. It would be much simpler to implement `SELECT a1 FROM nums GROUP BY a+1 AS a1`.
- deleted 7y ago[deleted]