Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • SQLPLUS COPY command Precautions. Oracle
  • Changing unix system clock when Oracle database is running. Oracle
  • Removing first line Linux/Unix
  • ORACLE_SID in sqlplus Oracle
  • Oracle Recommended Patches — Oracle Database ID 756671.1 Oracle
  • Nice Article about semaphores and init.ora Processes parameter relations Linux/Unix
  • AWR settings- MMON is not taking snapshot. Oracle
  • Renaming Oracle Instance Name Oracle
  • scripts to take listener.log backup Linux/Unix
  • Explain Plan Output 2 Oracle
  • Recovering lost SYS password Oracle
  • DB Console Mainenance. Oracle
  • Removing Ctrl-M from end of line using vi Linux/Unix
  • RAC 11g with vmware Oracle
  • New OFA for 11g 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

  • Oracle10g – Using SQLAccess Advisor (DBMS_ADVISOR) with the Automatic Workload Repository Oracle
  • DBA_HIST_SQLSTAT contents Oracle
  • In Addition to previous note, following grants needed on PERFSTAT user. Oracle
  • Example of How To Resize the Online Redo Logfiles Note:1035935.6 Oracle
  • eplan.sql Oracle
  • Giving Grant on v$DATABASE Oracle

Leave a Reply Cancel reply

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

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • 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

  • Complete Git Tutorial for Beginners25-Dec-2025
  • Postgres DB user and OS user.25-Dec-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • How to sort list of files on basis of their sizes. Linux/Unix
  • Search and replace editor command in vi Linux/Unix
  • Important Script Method for tuning Oracle
  • SQL Server: How to see current transactions or requests SQL Server
  • Alter procedure auditing Oracle
  • To find all disk io ( EMC as well as local) Linux/Unix
  • exp syntax in oracle 10g Oracle
  • Create type and Grant on it. Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme