I have 3 columns in Invoice table.

1. InvoicePeriod
2. InvoiceType
3. Fees

I have data like this:

```

InvoicePeriod  InvoiceType  Fees
2020-06-30     ABC          10.0
2020-06-30     ABC          40.0
2020-06-30     ABC          32.0
2020-09-30     ABC          5.0
2020-09-30     XYZ          30.0
2020-12-31     ABC          20.0
2020-12-31     ABC          10.0
2021-01-31     XYZ          60.0
2021-02-01     DEF          36.0

```

Now I want the last(max) of invoice period of each invoice type and the summation of fees of previous dates.

Output:

```

InvoicePeriod  InvoiceType  Fees
2020-12-31     ABC          87.0
2021-01-31     XYZ          30.0
2021-02-01     DEF          0.0

```

How can I achieve this?

Thanks,
Ankit