
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Get minimum value from a column (floating values) with corresponding duplicate ids in MySQL
To get minimum value from a column with corresponding duplicate ids, use GROUP BY and MIN() −
select min(yourColumnName) from yourTableName group by yourColumnName;
To understand the above syntax, let us create a table −
mysql> create table DemoTable2005 ( Id int, Price float ); Query OK, 0 rows affected (0.71 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2005 values(1,56.88); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable2005 values(1,120.56); Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable2005;
This will produce the following output −
+------+--------+ | Id | Price | +------+--------+ | 1 | 56.88 | | 1 | 120.56 | +------+--------+ 2 rows in set (0.00 sec)
Here is the query to get minimum value from a column wherein the corresponding column has duplicate ids −
mysql> select min(Price) from DemoTable2005 group by Id;
This will produce the following output −
+------------+ | min(Price) | +------------+ | 56.88 | +------------+ 1 row in set (0.00 sec)
- Related Articles
- Select minimum row value from a column with corresponding duplicate column values in MySQL
- MySQL rows concatenation to fetch maximum corresponding value from duplicate IDs?
- Add records from corresponding duplicate values in another column with MySQL
- MySQL query to fetch the maximum corresponding value from duplicate column values
- Display highest amount from corresponding duplicate ids in MySQL
- Find average of corresponding records (Product Price) from duplicate product ids in MYSQL
- Get the count of duplicate values from a single column in MySQL?
- Get first date from timestamp in MySQL group by another column with duplicate value
- Count duplicate ids and display the result in a separate column with MySQL
- Select a value from MySQL database only if it exists only once from a column with duplicate and non-duplicate values
- Update table with duplicate ids in MySQL
- MySQL to get only the floating-point numbers from a list of values in a column
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- How to combine duplicate values into one with corresponding value separated by hyphens in MySQL?
- Display duplicate record as a distinct value with corresponding values as distinct comma separated list in MySQL?

Advertisements