I have a lot of data that gets entered into a spreadsheet. There are 3 columns I have. A is the date of purchase, B is the type (wholesale or retail) and C is the value. Every day, they are updated. The issue is that in Column D1, I have the sum of all of the wholesale, and D2 has the sum of all of the retail. So on day 1, column D1 looks like:

=SUM(C1:C19)
but on day 2 it will be
=SUM(C1:C44)

and D2 will be
=SUM(C20:C999)
and day 2 it will be
=SUM(C45:C999)

Is there a way to make a function that will automatically detect and add up wholesale and retail prices?