0

i'm using 10.1.48-MariaDB serwer and i have a problem which i don't know how to describe :) so let me use an example.

How to select fruits with max. value in their group?

fruit    price  val
-------|------|---|
orange | 1.00 | 1 |
orange | 2.00 | 2 |
orange | 3.00 | 3 |
orange | 4.00 | 4 |
orange | 5.00 | 4 |
apple  | 2.00 | 1 |
apple  | 3.00 | 2 |
apple  | 4.00 | 2 |
apple  | 5.00 | 1 |
apple  | 6.00 | 1 |

sooo... i would like the result be like this

fruit    price  val
-------|------|---|
orange | 4.00 | 4 |
orange | 5.00 | 4 |
apple  | 3.00 | 2 |
apple  | 4.00 | 2 |
MeBugi
  • 3
  • 3
  • Hi just use this query below SELECT fruit, price, val FROM table WHERE val = (SELECT MAX(val) FROM table) – Kolajo Mar 07 '22 at 09:49

0 Answers0