Who knows SQL?

No, the best way is to use metadata

http://en.wikipedia.org/wiki/Oracle_metadata

  1. Find all columns (that is trivial using metadata)

  2. Construct SQL statement. select sum(a1), sum(a2)… group by b1, b2. Also trivial once you know the group by column. Group by columns are fixed

  3. Execute dynamic SQL to get result. All in all is pretty trivial.

Yes, that sounds pretty trivial. Is metadata now available in standard SQL, or is step zero, “migrate your database to Oracle?”

I had to urbandictionary that one.