Re: Can WINDOW be used?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> wxd0812=# EXPLAIN ANALYZE
> wxd0812-# SELECT * FROM
> wxd0812-#  (SELECT DISTINCT ON (key1_id,key2_id) * FROM sid120.data
> ORDER BY key1_id,key2_id,time_id DESC) x
> wxd0812-#  WHERE NOT deleted;

SELECT * FROM (
     SELECT data.*,
       rank() as rank over
            ( partition by key1_id, key2_id order by time_id DESC )
     FROM data
) as rankings
WHERE rank = 1 AND NOT deleted;


-- 
                                  -- Josh Berkus
                                     PostgreSQL Experts Inc.
                                     http://www.pgexperts.com

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux