Re: ERROR: ORDER/GROUP BY expression not found in targetlist

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ERROR: ORDER/GROUP BY expression not found in targetlist
Date: 2016-06-28 13:29:58
Message-ID: CA+HiwqF+EVK5ghNHAJsaz32Sb3hUDn0pUS5p1F3kZbOGJi+qWw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 28, 2016 at 2:52 PM, Rushabh Lathia
<rushabh(dot)lathia(at)gmail(dot)com> wrote:
> Hi,
>
> Consider the below testcase:
>
> CREATE TABLE tab(
> c1 INT NOT NULL,
> c2 INT NOT NULL
> );
> INSERT INTO tab VALUES (1, 2);
> INSERT INTO tab VALUES (2, 1);
> INSERT INTO tab VALUES (1, 2);
>
>
> case 1:
>
> SELECT c.c1, c.c2 from tab C WHERE c.c2 = ANY (
> SELECT 1 FROM tab A WHERE a.c2 IN (
> SELECT 1 FROM tab B WHERE a.c1 = c.c1
> GROUP BY rollup(a.c1)
> )
> GROUP BY cube(c.c2)
> )
> GROUP BY grouping sets(c.c1, c.c2)
> ORDER BY 1, 2 DESC;
> ERROR: ORDER/GROUP BY expression not found in targetlist
>
> case 2:
>
> create sequence s;
> SELECT setval('s', max(100)) from tab;
> ERROR: ORDER/GROUP BY expression not found in targetlist

The following give the same error:

select max(100) from tab;
select max((select 1)) from tab;

Thanks,
Amit

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2016-06-28 14:10:59 Re: Reviewing freeze map code
Previous Message Ashutosh Bapat 2016-06-28 12:20:50 Re: Postgres_fdw join pushdown - wrong results with whole-row reference