Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • 10g oem configuration Oracle
  • get_vmstat.ksh Linux/Unix
  • Drop database in Oracle 10g Oracle
  • Backup and Recovery Scenarios Oracle
  • eplan9i.sql Oracle
  • How to analyze statspack or AWR report. Oracle
  • ORA-8031 issue and solution if it is occuring due to truncate. Oracle
  • Oracle Support Metalink ID 161818.1 Oracle
  • Convert multiple rows to single column Oracle
  • Finding last recovered file on DR and remove all chanracters before any “/” Linux/Unix
  • Rman Notes -1 Oracle
  • oracle 10g on linux Linux/Unix
  • Remove DOS CR/LFs (^M) Linux/Unix
  • How to start CRS manually Oracle
  • Removing Ctrl-M from end of line using vi Linux/Unix

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

  • dbinv.sql Oracle
  • switchover for primary database Oracle
  • 339939.1 Running Cluster Verification Utility to Diagnose Install Problems Oracle
  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • pvm_metric.sql for gathering report from vmstat tables Oracle
  • find_log_switch.sql Find log switches in graphical manner Oracle

Leave a Reply Cancel reply

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

Categories

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

Recent Posts

  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • chk_space_SID.ksh Linux/Unix
  • database trigger failing Oracle
  • Benefits and Usage of RMAN with Standby Databases Oracle
  • usnsql.sql Displays information about UNDO segments with sql statements Oracle
  • ext#.sql Oracle
  • Formatter Explain plan Output 1 Oracle
  • Very Good Oralce Internal Tuning Book Oracle
  • How To Limit The Access To The Database So That Only One User Per Schema Are Connected (One Concurrent User Per Schema) Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme