Используя встроенную функцию списка, вы можете сделать это
a
out:[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
#Displaying the list
a.remove(a[0])
out:[[1, 1, 1, 1], [1, 1, 1, 1]]
# Removed the first element of the list in which you want altered number
a.append([5,1,1,1])
out:[[1, 1, 1, 1], [1, 1, 1, 1], [5, 1, 1, 1]]
# append the element in the list but the appended element as you can see is appended in last but you want that in starting
a.reverse()
out:[[5, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
#So at last reverse the whole list to get the desired list
использовать коррелированный подзапрос
select product_id , a.customer_id , age
from purchases a inner join customers b on a.customer_id =b.customer_id
where age in (select max(age) from purchases a1 inner join customers b1 on a1.customer_id =b1.customer_id where a.product_id=a1.product_id group by a1.product_id)