I have a table with field 'code' => '002' duplicate data.
---------------------------
| # | code | name | value |
----------------------------
| 1 | 001 | A | 2 |
| 2 | 002 | B | 4 |
| 3 | 002 | B | 6 |
| 4 | 003 | C | 3 |
| 5 | 004 | D | 1 |
---------------------------
All I want to do is to remove duplicate data and choose the higher value. The result is something like this.
---------------------------
| # | code | name | value |
----------------------------
| 1 | 001 | A | 2 |
| 2 | 002 | B | 6 |
| 3 | 003 | C | 3 |
| 4 | 004 | D | 1 |
---------------------------
I've tried query using DISTINCT but only show for single field. I really have no ideas to show all field with no duplicate data.
Please someone help me to figure this out.
thank you so much.