I have 100 different data of sales for different companies, company A B C and D.

Column 1: Company Name
Column 2: Date of sales

How do i list out the last/newest 5 data for company A from the whole list of data and average them?