Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2004
    Posts
    4

    Exclamation Unanswered: Dynamic Query :: HELP!

    I'm the new guy and I could use a hand. Any insight would be appreciated.

    Basically my task is to create a dynamic way to merge columns from multiple rows. Way the table is set up data is imported and one entry may be up to 3 rows one column from each row can be merged to form a long description, I would like to create a view that would allow you to dynamically query this data and have the description be merged in the result set.

    row1 x y z
    row2 x b z
    row3 x m z


    results should look like :: x, (y + b + m) , z


    Thank you in advance for any help you can provide!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    numbers? you can SUM() them, but description? can't be done

    you'll need to write some sort of script, either in the application that calls the database, or mayhaps in a stored proc that can cursor through the rows
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2004
    Posts
    4
    Quote Originally Posted by r937
    numbers? you can SUM() them, but description? can't be done

    you'll need to write some sort of script, either in the application that calls the database, or mayhaps in a stored proc that can cursor through the rows

    Unfortunately the data is all of char type.

  4. #4
    Join Date
    Oct 2004
    Posts
    4
    Any suggestions of how to go about doing this using a procedure?

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  6. #6
    Join Date
    Oct 2004
    Posts
    4
    Thanks for the link...I can't say I totally understand the function though.

    I hate to ask this, and sound like an idiot, but can anyone give me the english break down?

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Cut and paste this code in to Query Analyzer...

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40520
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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