pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
equivalent of oracle rank() in postgres 2+ messages / 2 participants [nested] [flat]
* equivalent of oracle rank() in postgres @ 2005-03-21 07:08 Chandan_Kumaraiah <Chandan_Kumaraiah@satyam.com> 0 siblings, 1 reply; 2+ messages in thread From: Chandan_Kumaraiah @ 2005-03-21 07:08 UTC (permalink / raw) To: pgsql-sql Hi, Jus wanted the equivalent for rank() as in tis example.. SELECT * FROM ( SELECT employee_id, last_name, salary, RANK() OVER (ORDER BY salary DESC) EMPRANK FROM employees) WHERE emprank = 3; Rgds, Chandan ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: equivalent of oracle rank() in postgres @ 2005-03-22 02:52 Greg Sabino Mullane <greg@turnstep.com> parent: Chandan_Kumaraiah <Chandan_Kumaraiah@satyam.com> 0 siblings, 0 replies; 2+ messages in thread From: Greg Sabino Mullane @ 2005-03-22 02:52 UTC (permalink / raw) To: pgsql-sql -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Jus wanted the equivalent for rank() as in tis example.. > SELECT * > FROM ( > SELECT employee_id, last_name, salary, > RANK() OVER (ORDER BY salary DESC) EMPRANK > FROM employees) > WHERE emprank = 3; There is no direct equivalent to rank(), but there are certainly other ways to get the results. The above query can be written in PostgreSQL as: SELECT employee_id, last_name, salary FROM employees WHERE salary = (SELECT DISTINCT salary FROM employees ORDER BY salary DESC OFFSET 2 LIMIT 1); - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200503212152 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFCP4hwvJuQZxSWSsgRAoKPAKDE0pB4NueE0Dh9EfJiXw79SvCDoACcC4xb ydxVgK9DgGHQXJqFIrlHIIo= =GRIX -----END PGP SIGNATURE----- ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-03-22 02:52 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2005-03-21 07:08 equivalent of oracle rank() in postgres Chandan_Kumaraiah <Chandan_Kumaraiah@satyam.com> 2005-03-22 02:52 ` Greg Sabino Mullane <greg@turnstep.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox