Subquery uses ungrouped column

From: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Subquery uses ungrouped column
Date: 2016-05-26 16:02:15
Message-ID: 68c84834-70a5-a707-d74a-e0cde953d470@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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" from
outer query
LINE 3: where id = substring(fileid from -1)

but the following query:

SELECT (select msc_id
from collectors
where id = fileid
) msc_id
from ip_data_records
group by fileid

is working ok?

--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-05-26 16:32:34 Re: Subquery uses ungrouped column
Previous Message Thomas Güttler 2016-05-26 15:03:25 Re: Do docs miss information about timing of triggers?