Sql Select Where Max Function In Python For Dictionary