reverse pivot and aggregate functions