We have to divide the total dollar amount by the number of grams to get he unit rate for each.
The First One:
145/5 = 29 dollars per g
The Second One:
264/8 = 33 dollars per g
So, we can see that:
The first one is better deal with a unit rate of 29 dollars per g.