- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Query to find Nth maximum value in MySQL
Let us first create a table −
mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(85); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output−
+-------+ | Value | +-------+ | 40 | | 60 | | 45 | | 85 | | 78 | +-------+ 5 rows in set (0.00 sec)
Following is the query to find Nth maximum value in MySQL −
mysql> select * from DemoTable order by Value desc limit 2,1;
This will produce the following output −
+-------+ | Value | +-------+ | 60 | +-------+ 1 row in set (0.00 sec)
- Related Articles
- MySQL query to fetch the maximum cumulative value
- MySQL query to select the nth highest value in a column by skipping values
- How to find nth highest value of a MySQL column?
- MySQL query to fetch the maximum corresponding value from duplicate column values
- Select nth highest value in MySQL
- How to return the nth record from MySQL query?
- Find the Maximum Value in a Column in MySQL
- How to find the minimum and maximum values in a single MySQL Query?
- Find maximum value from a VARCHAR column in MySQL
- MySQL query to find a value appearing more than once?
- MySQL query to find sum of fields with same column value?
- Limiting numbers to a maximum value in MySQL?
- MySQL query to select maximum and minimum salary row?
- MySQL query to replace a column value
- MySQL query to find same value on multiple fields with LIKE operator?

Advertisements