
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch Maximum Value from a MySQL Column
Let us first create a table −
mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(58); Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Value | +-------+ | 78 | | 89 | | 98 | | 58 | +-------+ 4 rows in set (0.00 sec)
Following is the query to get the maximum value from a column −
mysql> select Value from DemoTable order by Value DESC limit 1;
This will produce the following output −
+-------+ | Value | +-------+ | 98 | +-------+ 1 row in set (0.00 sec)
Advertisements