Joe, Elein:
> This is pretty much exactly how contrib/tablefunc's crosstab (non-hashed
> version; crosstab(sourcesql, ncols)) works. If you really need it to be
> portable, though, application layer procedural code is likely to be the
> easiest and fastest way to go. crosstab just wraps the procedural code
> in an SRF for you.
No, you're missing one factor in the spec. Timekeeper_1 for case_id = 182738
is not the same timekeeper as Timekeeper_1 for case_id = 217437. That's why
traditional crosstab plans don't work.
Anyway, here's the wrap-up: I tried Stephan's idea, it works, but it's so
slow that we're going to to the procedural loop. Thanks, all!
--
Josh Berkus
Aglio Database Solutions
San Francisco