Question: I have a table like this:

```
| Key | Value | Message |
|-----|-------|---------|
| a   | 1     | xx      |
| a   | 2     | yy      |
| b   | 5     | mm      |
| b   | 4     | nn      |

```

I would like to group the data by Key, get the minimum Value of each group, and the related Message.
The result is expected to be:

```
| Key | Value | Message |
|-----|-------|---------|
| a   | 1     | xx      |
| b   | 4     | nn      |

```

I'm using MySQL 5.7. Is it possible to do that?

Answer: 
You can try below -

```
select * from tablename a
where value = (select min(value) from tablename b where a.key=b.key)

```
Use this Query

```
select * from table_name tab1
where value in ( select MIN(value) from table_name tab2
                where tab2.[key] = tab1.[key] )

```