I have a table with data as fleet table data:
I'm trying to get the MAX aircraft_count
for each carriercode
along with the rest of the columns.
I know this works but I can't get the rest of the columns
select carriercode, max(aircraft_count) as peak
from fleet
group by carriercode;
This is the closest I have come.
select f1.id, distinct(f1.carriercode), f1.aircraft_count, f1."timestamp"
from fleet f1
where f1.aircraft_count =
(select max(f2.aircraft_count)
from fleet f2
where f1.carriercode = f2.carriercode)
order by f1.aircraft_count desc;
Expected result:
id - carriercode - max_count - timestamp
10 - EIN - 100 - 2016-03-27 23:07:49.121449
252 -SCO - 34 - 2016-03-27 23:07:53.282367