How to select and get a total for purchases