I've tried reading through a number of the solutions I've found, but there seem to be slight differences in the problems where I'm not sure how to adapt them to fit my own.
I have a table of transactions like so:
+------+-------+------------------------------+
| id | rev_$ | product | local_currency |
+------+-------+------------------------------+
| 1 | 15 | shoe | USD |
| 2 | 10 | shirt | USD |
| 1 | 20 | shoe | CAD |
| 2 | 30 | shoe | GBP |
| 1 | 8 | shirt | USD |
| 2 | 15 | shirt | USD |
| 1 | 10 | shoe | CAD |
| 2 | 10 | shoe | USD |
+------+-------+------------------------------+
I want to aggregate the table so that
- I get the total for each ID by product
- The
local_currency
is the currency used for the highest single value transaction (as well as other fields that I haven't included)
So that table should look like this, after aggregating:
+------+-------+------------------------------+
| id | rev_$ | product | local_currency |
+------+-------+------------------------------+
| 1 | 45 | shoe | CAD |
| 1 | 8 | shirt | USD |
| 2 | 25 | shirt | USD |
| 2 | 40 | shoe | GBP |
+------+-------+------------------------------+