Answers for "group by and get max value"

SQL
0

group by max date

SELECT train, dest, time FROM ( 
  SELECT train, dest, time, 
    RANK() OVER (PARTITION BY train ORDER BY time DESC) dest_rank
    FROM traintable
  ) where dest_rank = 1
Posted by: Guest on August-09-2021
0

get maximum value index after groupby

You can sort the dataFrame by count and then remove duplicates. I think it's easier:
df.sort_values('count', ascending=False).drop_duplicates(['Sp','Mt'])
Posted by: Guest on December-06-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language