Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts

    Changing structure based on data

    I have got a very mean task to deliver.

    consider i have the following data:
    Code:
    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:
    Code:
    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

    thanks
    I am the luckiest man in the world

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    it was a mean beast, but i finally found the way to do it, thanks for the thinking some of you did.
    I am the luckiest man in the world

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome.

    I got to the part where i needed to know which db-format you used
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    solution is db-independent, just some plain old joins and where clauses
    I am the luckiest man in the world

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Which is almost the most efficient way
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •