Re: [GENERAL] Subquery uses ungrouped column

2016-05-26 Thread Tom Lane
"David G. Johnston" writes: > From observation PostgreSQL doesn't recognize the equivalency of the > outer "group by substring(fileid from -1)" and the subquery expression. Well, it would without the subselect in between. There's a code comment in parse_agg.c about this: * NOTE: we recognize g

Re: [GENERAL] Subquery uses ungrouped column

2016-05-26 Thread David G. Johnston
On Thu, May 26, 2016 at 12:02 PM, Alex Ignatov wrote: > Hello! > > Why the following query: > > SELECT (select msc_id > from collectors > where id = substring(fileid from -1) >) msc_id >from ip_data_records >group by substring(fileid from -1) >

[GENERAL] Subquery uses ungrouped column

2016-05-26 Thread Alex Ignatov
Hello! Why the following query: SELECT (select msc_id from collectors where id = substring(fileid from -1) ) msc_id from ip_data_records group by substring(fileid from -1) gives me: ERROR: subquery uses ungrouped column "ip_data_records.fileid"