Q:

How to rank on criteria AND account for duplicate values

What I would like to achieve
I would like to rank by the cheapest prices per quarter, as well as accounting for duplicate prices. I have included an example below, along with how the 'Rank' column should look:
   A     B      C
1  Qtr  Price  Rank
2  2     10     2
3  2     10     2
4  2     10     2
5  2      6     1
6  3     12     3
7  3     10     2
8  3     8      1
9  3     8      1

What I have tried
I have tried this "=SUMPRODUCT(--($A$2:$A$9 = A2),--(B2>$B$2:$B$9))+1)" in cell C2 but the rank order skips values and returns the following:
   A     B      C
1  Qtr  Price  Rank
2  2     10     2
3  2     10     2
4  2     10     2
5  2      6     1
6  3     12     4
7  3     10     3
8  3     8      1
9  3     8      1

I have also tried "=COUNTIFS($A$2:$A$9,A2,$B$2:$B$9,"<"&B2)+1" however this spits out the same values as above.
I can't find anything online that is able to account for duplicates AND criteria (Quarter number in this case), so I would appreciate any help do this.

A:

=SUMPRODUCT(((A2=$A$2:$A$9)*(B2>=$B$2:$B$9))/COUNTIFS($B$2:$B$9,$B$2:$B$9,$A$2:$A$9,$A$2:$A$9))

in A2
Adapt the range in the formula to your last record if needed (only goes to A9 in this example)

