View Full Version : Changing structure based on data

04-07-2004, 02:41 PM
I have got a very mean task to deliver.

consider i have the following data:

class_id object_id date_val name
455 1 9-4-2004 Datum_start_behandeltermijn
455 1 19-4-2004 Datum_beslissing
455 2 19-4-2004 Datum_start_behandeltermijn
455 2 1-5-2004 Datum_beslissing

but for each unique combination of class_id and object_id there can be more name value pairs as records in this database

what i would like to transform this into is:

class_id object_id Datum_start_behandeltermijn Datum_beslissing
455 1 9-4-2004 19-4-2004
455 2 19-4-2004 1-5-2004

each record in the original table holds a name and a value of a data-element
what i want is the name of the element to become a column-name in the transformed table where the value is in this column
does anyone know enough SQL statements to perform this transformation

this is needed to produce management information


04-08-2004, 01:23 PM
it was a mean beast, but i finally found the way to do it, thanks for the thinking some of you did. :rolleyes:

04-08-2004, 02:02 PM
You're welcome.

I got to the part where i needed to know which db-format you used :rolleyes:

04-08-2004, 02:57 PM
solution is db-independent, just some plain old joins and where clauses

04-08-2004, 03:16 PM
Which is almost the most efficient way :rolleyes: