Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Export Import with QUERY Oracle
  • CTAS with LONG Column for 7.x and 8 and 8i Oracle
  • Unix command for system configuration Linux/Unix
  • ENQ: KO – FAST OBJECT CHECKPOINT tips Oracle
  • Processes Parameter decision Oracle
  • How to connect to Oracle Database with Wallet with Python. Oracle
  • Which environment is used by currently running process ( Very good) Linux/Unix
  • sqlnet.ora paramters Oracle
  • Oracle Material from OTN Oracle
  • DBMS_JOB all example Oracle
  • export import with parameter file. Oracle
  • scp with ssh2 Linux/Unix
  • Identical Dblink Issue… Oracle
  • Display the top 5 salaries for each department using single SQL Oracle
  • Temporary Tablespace Information and restriction. Oracle

Find nth max and min.

Posted on 02-May-2007 By Admin No Comments on Find nth max and min.

First, the query for Max:

SELECT * FROM TAB1 a

WHERE &N = (SELECT count(DISTINCT(b.col1))

FROM TAB1 b WHERE a.col1<=b.col1) Next, the query for Min:
SELECT * FROM TAB1 a

WHERE &N = (SELECT count(DISTINCT(b.col1))

FROM TAB1 b WHERE a.col1>=b.col1)

If N=1 will return first max or first min. N=2 will return second max or min.

Oracle, SQL scripts

Post navigation

Previous Post: DBMS_Shared_pool pinning triggers
Next Post: Changing Instance Name ( No DB_NAME)

Related Posts

  • Goldengate Tutorial Oracle
  • OEM-Commnds Oracle
  • Rman Notes -1 Oracle
  • Find average Row Length and other table size calculation. metalink notes Oracle
  • TABLE SIZING WITH DB_BLOCK ARCHITECTURE Reference : Metalink note : 10640.1 Oracle
  • Goog notes on X$ tables Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • When error comes for temporary tablespace with version <= 9i Oracle
  • v$event_name Oracle
  • Global Unique Identifier Generation in Oracle 9.2 SYS_GUID() Oracle
  • Search and replace pattern Linux/Unix
  • Parallel DML Oracle
  • Establishing trusted relationship between dbmonitor( central monitoring) and monitoring targets. Linux/Unix
  • The most important Tuning Notes Oracle
  • normal maintenance for exp-imp and renaming table Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme