Re: [HACKERS] Re: Question regarding new windowing functions in 8.4devel

From: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
To: "David Fetter" <david(at)fetter(dot)org>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] Re: Question regarding new windowing functions in 8.4devel
Date: 2009-01-16 17:23:16
Message-ID: 3073cc9b0901160923v8f08c5eqcd4a2d4ac8ba6694@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, Jan 16, 2009 at 12:07 PM, David Fetter <david(at)fetter(dot)org> wrote:
>>
>> Now i want only 3 records for every typ:
>>
>> test=# select typ, ts, rank() over (partition by typ order by ts desc ) from foo where rank <= 3;
>> ERROR: column "rank" does not exist
>> LINE 1: ...rtition by typ order by ts desc ) from foo where rank <= 3;
>

maybe the rank should go in a having clause? i'm not familiar about
window functions yet... just guessing...

> I tried this:
>
> SELECT
> typ,
> ts,
> rank() over w AS foo_rank
> FROM
> foo
> WINDOW w AS (partition by typ order by ts desc)
> WHERE
> foo_rank < 4;
>
> ERROR: syntax error at or near "WHERE"
> LINE 8: WHERE
> ^

the WINDOW specification goes after the WHERE clause not before

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-01-16 17:33:06 Re: [HACKERS] Re: Question regarding new windowing functions in 8.4devel
Previous Message David Fetter 2009-01-16 17:07:32 Re: Question regarding new windowing functions in 8.4devel

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2009-01-16 17:33:06 Re: [HACKERS] Re: Question regarding new windowing functions in 8.4devel
Previous Message Joshua D. Drake 2009-01-16 17:20:29 Re: FWD: Re: Updated backslash consistency patch