- 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
Get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns?
Let us first create a table −
mysql> create table DemoTable ( Value varchar(100) ); Query OK, 0 rows affected (0.75 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('190'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('230'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('120'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('189'); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Value | +-------+ | 190 | | 230 | | 120 | | 189 | +-------+ 4 rows in set (0.00 sec)
Following is the query to get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns −
mysql> select min(cast(Value AS SIGNED)) AS Min, max(cast(Value AS SIGNED)) AS Max from DemoTable;
This will produce the following output −
+------+------+ | Min | Max | +------+------+ | 120 | 230 | +------+------+ 1 row in set (0.03 sec)
- Related Articles
- Count duplicate ids and display the result in a separate column with MySQL
- Find maximum value from a VARCHAR column in MySQL
- Select distinct names from two columns in MySQL and display the result in a single column
- Display the sum of positive and negative values from a column in separate columns with MySQL
- MySQL query to get the length of all columns and display the result in a single new column?
- Divide numbers from two columns and display result in a new column with MySQL
- MySQL query to count the duplicate ID values and display the result in a separate column
- Get the highest score value from a single column and the greatest from two columns in MySQL
- Get the minimum value from a list with multiple columns in MySQL?
- Getting the maximum value from a varchar field in MySQL
- Display the count of duplicate records from a column in MySQL and order the result
- How to sum varchar column and display the count in MySQL?
- Get MySQL maximum value from 3 different columns?
- How to get a value more than a particular value from varchar column in MySQL?
- Concatenate date and time from separate columns into a single column in MySQL

Advertisements