8 ms·
very legacy?
by mephi5t0 13y ago
very legacy?
- lsb 13y agomuch inconsistent. One nifty feature of Postgresql is that if you have a group by a,b,c,d, you need to aggregate everything else in your select that isn't a/b/c/d, or the statement won't prepare, whereas if you don't select an aggregate in MySQL you'll just get one random column, which is probably not what you want.
- pjungwir 13y agoThis is mostly true, but in recent Postgres versions (since 9.1 I believe), if you GROUP BY the primary key, you can still include other columns in the SELECT statement. For instance: SELECT a.name, COUNT(b.id) FROM a LEFT OUTER JOIN b ON b.a_id = a.id GROUP BY a.id Pretty nice!