- 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
Find the next lowest number higher than a certain number in MySQL?
For this, use aggregate function MIN() along with WHERE clause. Let us first create a table −
mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(11); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(9); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(12); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Number | +--------+ | 11 | | 9 | | 10 | | 12 | +--------+ 4 rows in set (0.00 sec)
Following is the query to find the next lowest number higher than a certain number in MySQL −
mysql> select min(Number) from DemoTable where Number > 10;
This will produce the following output −
+-------------+ | min(Number) | +-------------+ | 11 | +-------------+ 1 row in set (0.00 sec)
- Related Articles
- Next higher number with same number of set bits in C++
- Find the Next perfect square greater than a given number in C++
- Next higher number using atmost one swap operation in C++
- Pull row with lowest number in a MySQL column?
- What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?
- Find Next Sparse Number in C++
- How to calculate the number of elements greater than a certain value in a vector in R?
- Next greater Number than N with the same quantity of digits A and B in C++
- MySQL query to get the next number in sequence for AUTO_INCREMENT field?
- Program to find higher number with same number of set bits as n in Python?
- Find lowest Date (custom) in MySQL?
- Finding next prime number to a given number using JavaScript
- Guess Number Higher or Lower in C++
- JavaScript Array showing the index of the lowest number
- Program to find maximum difference of any number and its next smaller number in Python

Advertisements