Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • On solaris 10, “S” link is not part of $ORACLE_HOME/bin/oracle as default. ( For 9.2.0.8) Oracle
  • Important Script Method for tuning Oracle
  • Zip and unzip with tar Linux/Unix
  • How do I get Oracle to automatically start when my server boots up? Oracle
  • RMAN : Consistent Backup, Restore and Recovery using RMAN Oracle
  • dbinv.sql Oracle
  • 272332.1 CRS 10g Diagnostic Collection Guide Oracle
  • Find all users who have DML privileges Oracle
  • pvm_metric.sql for gathering report from vmstat tables Oracle
  • Renaming the column name Oracle
  • Optimizer_Index init.ora parameter explaination. Oracle
  • Goldengate document from Porus Oracle
  • age_alert.ksh aging out alert.log Linux/Unix
  • Find All internal Parameters Oracle
  • How does one SELECT a value from a table into a Unix variable? From SQL to Shell 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

  • online_bkup.sql Oracle
  • load SPM baseline from cursor cache Oracle
  • UNderstand and eliminate Latch contention. Oracle
  • Monitor Long Running Job Oracle
  • Jai Shree Ram Oracle
  • pvm_rbs1.sql (to collect rbs info from db) 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
  • ORA-4031 issue and solution on 09-MAY-2008 Oracle
  • Privileges Required to Create Procedures and Functions that uses objects from other schema. Oracle
  • moving lob object to other tablespace lob_mvmt.sql Oracle
  • Resolving RMAN Hung Jobs Oracle
  • Implementing Listener Security Oracle
  • Settting up get_vmstat.sh for colletinf CPU Usage. Oracle
  • segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used) Oracle
  • Guide to Linux System Command Mastery Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme