
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Fetch the 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)
- Related Articles
- Two ways to fetch maximum value from a MySQL column with numbers
- MySQL query to fetch the maximum corresponding value from duplicate column values
- Find maximum value from a VARCHAR column in MySQL
- MySQL query to fetch the maximum cumulative value
- Fetch a specific column value (name) in MySQL
- MySQL rows concatenation to fetch maximum corresponding value from duplicate IDs?
- Find the Maximum Value in a Column in MySQL
- Fetch maximum value from a column with values as string numbers like Value440, Value345, etc. in SQL
- Fetch a single ordered date from a column with MySQL LIMIT
- Fetch the first letter of a column value and insert it in another column with MySQL
- How to select the maximum value of a column in MySQL?
- Get the maximum value of a column with MySQL Aggregate function
- Getting maximum from a column value and set it for all other values in the same column with MySQL?
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- Get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns?

Advertisements