Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337

    Unanswered: Named partitions/windows

    A few weeks ago I ran across an example where you could reuse the same partition in an analytic query. Now I need to use it but I can't find a reference to it anywhere.

    It went something like:
    Code:
    SELECT rank() OVER partition_foo,
      lag(bar) OVER partition_foo,
      lead(bar) OVER partition_foo
      -- somehow defining partition_foo once

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    PostgreSQL supports naming of windows, but I don't think Oracle does.

    In PostgreSQL (and I think in "ANSI SQL") the syntax would be:
    Code:
    SELECT rank() OVER partition_foo,
      lag(bar) OVER partition_foo,
      lead(bar) OVER partition_foo
    FROM some_table
      WINDOW partition_foo AS (PARTITION BY foobar ORDER BY barfoo DESC);

  3. #3
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    That would explain why I couldn't find it in Oracle's documentation. I was wondering if it hadn't been on MS SQL or Postgres... that's the trouble with working on too many databases.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •