Results 1 to 12 of 12

Thread: Help needed!!

  1. #1
    Join Date
    Feb 2004
    Posts
    2

    Question Unanswered: Help needed!!

    Hello guys,
    I'm new to the forum and to MS SQL 2K.
    I'm trying to a merge similar rows in a table into a single row and put them in a new table.

    Example:-
    This is my input table
    TableA
    ID A B C
    ------------------------
    1 jk kl bj
    2 sd we op
    3 io po kl
    1 ui gh ew
    2 kl re op
    1 qw kj nn

    My output table should look like this
    TableB
    ID A1 B1 C1 A2 B2 C2 A3 B3 C3
    -----------------------------------------------------
    1 jk kl bj ui gh ew qw kj nn
    2 sd we op kl re op
    3 io po kl

    Please help me on how to create my output.
    Thanks in advance,

    Sid.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You want help violating the rules of normalization? Should I buy you a carton of cigarettes while I'm at it? Neither activity is healthy.

    Seriously, if you must do this it is important to know whether the number of records for an ID is fixed or not. If it can be any number then you are not going to be able to define the columns on your output table ahead of time and you are left with a messy dynamic query task. If there is a limit on the number of records per ID then your problem is merely a moderately difficult cross-tab query.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Feb 2004
    Location
    San Antonio, TX
    Posts
    565
    normalization or not
    this is a good exercise to displace data
    kinda like playing scales before you actually play a song on an instrument

    i will be working on this tonight

  4. #4
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    I'll check this query today ...

  5. #5
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    giving up

    I don't understand to purpose of this query

  6. #6
    Join Date
    Feb 2004
    Location
    San Antonio, TX
    Posts
    565
    i now have a headache

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    There's not much point in pursuing this without further clarification from coolhandsid, so save the Tylenol.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  8. #8
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    I've got

    Table1
    ID | A | B | C
    1 | 2 | 3 | 4
    2 | 9 | 4 | 5
    3 | 22| 53 94


    I want this result

    Table1
    ID X Y Z
    1 | 81 | April | NULL
    Y | 12 | Dog | Sheep
    12.3 | Cherry | Spain | 3

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I've got broccolli and I want lobster. I can't make one out of the other either.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  10. #10
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Remeber the MASH episode (when they used to be good) when they made the spam lamb for the turkish troops?
    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.

  11. #11
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Originally posted by blindman
    You want help violating the rules of normalization? Should I buy you a carton of cigarettes while I'm at it? Neither activity is healthy.
    I would not want you doing the first ... but you can certainly buy that carton of cigs for me ...
    Get yourself a copy of the The Holy Book

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

  12. #12
    Join Date
    Feb 2004
    Posts
    2
    Thanks for all your help ,

    I figured it out , it can be down by a DTS package or a cross-tab query.

    Sid.

    Originally posted by Karolyn
    I've got

    Table1
    ID | A | B | C
    1 | 2 | 3 | 4
    2 | 9 | 4 | 5
    3 | 22| 53 94


    I want this result

    Table1
    ID X Y Z
    1 | 81 | April | NULL
    Y | 12 | Dog | Sheep
    12.3 | Cherry | Spain | 3

Posting Permissions

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