Python Find Minimum Index In Sql