-1
id      value     created_at
1       55        2018-07-16
2       25        2018-07-16
3       50        2018-07-16
1       100       2018-07-16
1       5         2018-07-16
3       11        2018-07-16
4       6         2018-07-16

How can I bring back each id (1, 2, 3, 4) but only the highest value record of each in an array?

1 = 100, 2 = 25, 3 = 50, 4 = 6

Community
  • 1
  • 1
lastone
  • 99
  • 1
  • 8

1 Answers1

0

Use MAX and GROUP BY

select id, MAX(value)  from 
your_table group by id
Bleach
  • 561
  • 4
  • 11