In this question It said (X.TotalBillAmount > mid1) means only those bills whose value is greater than mid1
in second if condition (X.TotalBillAmount > mid2) means it include both bills whose value is greater than mid2 and also mid1
In third if condition (X.TotalBillAmount > mid3) means it include all bills whose value is greater than mid3 (that means it include mid2 and mid1also)