df.client_id.value_counts()
df.client_id.value_counts().to_frame(name='count')
new_df.index.name = 'my_index'
new_df.columns = ['count']
select C.Name,
(select max(T.Phone) from Telephone T where T.Name = C.Name) Max_Phone
from Clients C
select
u.*,
ph.phone_max
from users u
left join (
select
user_id, max(phone) phone_max
from phones
group by user_id
) ph on u.user_id=ph.user_id
student_tuples = [
... ('john', 'A', 15),
... ('jane', 'B', 12),
... ('dave', 'B', 10),
... ('dave1', 'B', 11),
... ('dave2', 'B', 1),
... ]
... student_tuples.sort(key=lambda student: (student[1], student[2]))
student_tuples
[('john', 'A', 15), ('dave2', 'B', 1), ('dave', 'B', 10), ('dave1', 'B', 11), ('jane', 'B', 12)]