Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2005
    Posts
    266

    Unanswered: one line for 3 rows

    for MS SQL 2000
    I am having :

    Table1

    ID | N1 | N2 | N3 |
    -------------------
    12 | A | | |
    12 | | B| |
    12 | | | C|

    how can I get :

    12,A,B,C ?

    thank you for helping

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    select id, max(n1), max(n2), max(n3) from Table1 group by id
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Dec 2005
    Posts
    266
    Thank you roac

  4. #4
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Just to ask a quick question : why is your table laid out like that?
    I'm just curious to know if this can be related to a real world example.

  5. #5
    Join Date
    Dec 2005
    Posts
    266
    we are getting datas in this way from another application and we cannot change it
    I am taking the datas to put them in another table to read them normally for our application

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    what happens when you get more than 1 value in any given column?
    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.

  7. #7
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    In what format is this other application giving you data? Is the application writing directly to your database?

    If you are handling the data before it gets entered into your database then I would seriously reconsider a redesign of the table format and of the way you are inserting data. There is no normalisation here, which is half the point of a database structure.

    I don't see why the data cannot just be written into one row:
    i.e.

    ID| N1|N2|N3
    -------------------
    12 | A | B | C

    Do you have a more meaningful example of the data you are using? What datatypes are you utilising?

Posting Permissions

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