I have a table like this:
value ts
2.0 1
3.0 5
7.0 3
1.0 2
5.0 4
I need to select max value, min value and value with max ts. Is it possible to do it with one query? Is there an aggregate function which returns the first value from table? If so, I could do something like
select max(value), min(value), first(value) from table order by ts desc;
(For this query max value is 7.0, min value is 1.0, and value with max ts is 3.0)
2
Answers
You can do:
Result:
See example at DB Fiddle.