[RESOLVED] Sewing a Record
That ought to be an interesting subject line.
Suppose you perform a query that returns a collection of records. In those records, you care about only a single field, but would like to see all the fields from all the records in a single record. In other words, if the query returns these records:
A
B
C
D
I would like to turn that into a single record that looks like this:
A B C D
This example is a bit misleading. In the first set of records, the field that I want is always the same, so if the records are
the letters, and the field I want is always field N from each record, then the resulting row would really be:
A(N), B(N), C(N), D(N)
This could be done in code fairly easily. In fact, I can add some things to the records such that it would work even better in code, but doing this in code is also going to be fairly slow. What I would have to do would be to create a datatable with a column for each field, then create a datarow and add the contents into each column of the row. What I would like to know is whether or not I could do this in SQL, as I would expect that the SQL solution, if it exists, would be faster?
Re: [RESOLVED] Sewing a Record
Unfortunately because of the way PIVOT works, it has to be an aggregate function of some kind... in my casse it didn't matter since there was only one combination of ID/Value/Attribute...
-tg