I need to do grouping based on various aggregates, but the way my table
is set up (it can't change) is making things kind of difficult.
My table looks something like this:
Id | id_customer | id_datatype | content
----------------------------------------
1 | 25 | 1 | John
2 | 25 | 2 | Globochem
3 | 25 | 3 | 845.92
4 | 26 | 1 | Patty
5 | 26 | 2 | Globochem
6 | 26 | 3 | 284.92
7 | 27 | 1 | Sam
8 | 27 | 2 | Toxichem
9 | 27 | 3 | 1239.47
Datatype 1 = Name, 2 = Company, 3 = account balance.
I need to do an aggregate function on content where id_datatype = 3, and
then group by content where id_datatype = 2
So, say I wanted to do a sum function, it would end up with something
like:
Company | Sum
-------------------
Globochem | 1130.84
Toxichem | 1239.47
The content isn't static, so I can't use static names for content in the
query.
Any ideas on this one?