Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Good notes on Oracle Events Oracle
  • Check_recovery.sh program to run sqlplus and return its values remotely. Linux/Unix
  • Goldengate Tutorial Oracle
  • Benefits and Usage of RMAN with Standby Databases Oracle
  • Privileges Required to Create Procedures and Functions that uses objects from other schema. Oracle
  • To Find Orphan OS processes. Linux/Unix
  • SCRIPT TO LIST RECURSIVE DEPENDENCY BETWEEN OBJECTS UTLDTREE.sql Oracle
  • How to find the real execution plan and binds used in that explain plan in Oracle 10g?? Oracle
  • mutex in Oracle 10.2.0.2 or Oracle 10g Oracle
  • Sample WW22 listener.ora Oracle
  • set_env_dba Linux/Unix
  • Jai Shree Ram Oracle
  • Absolute file number and relative file number Oracle
  • RMAN : Consistent Backup, Restore and Recovery using RMAN Oracle
  • move_arch_files.ksh 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

  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • DB Console Mainenance. Oracle
  • lck.sql Oracle
  • SQL Tracker by SID sqltrackerbysid.sql Oracle
  • fkwoindex.sql /* Find FK without Index */ Oracle
  • In Addition to previous note, following grants needed on PERFSTAT user. 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 (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Does DBMS_JOB recompute the NEXT_DATE interval after or before Oracle
  • before_trunc.sql Before Truncate table needs to execute following: Oracle
  • currwait.sql Oracle
  • SYSOPER Mystery Oracle
  • Some useful Unix Commands Linux/Unix
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • restarting network in linux Linux/Unix
  • Proc code Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme