A few months ago our vendor added a capability to our ticketing system which lets us add any number of custom fields to a ticket. I'd like to query these fields out along with the other call information for reporting purposes, but each extensible field is stored as a row in the database. So basically you have something like this:
ext_doc_no call_record value
1 1001 Test
2 1001 test2
3 1001 moretest
What I'd like is to query back:
1001 Test test2 moretest
I've tried to use PIVOT, but that's rather demanding about things like using an aggregate function. Any other ideas on how to do this?
EDIT: I also tried querying each row separately into the main query, and using a function... but both methods are way too slow. I need something to get all the rows at once, PIVOT them and then join into the main query.