Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2006
    Posts
    1

    Unanswered: two rows to one column

    How to put two rows of data in one column?
    from
    dealID dealNO
    1 888
    1 999

    to
    dealID dealNO
    1 888,999

    you can't use create permission, so can't create storedprocedure.
    Pls help.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Without create permission you are screwed. You need either a stored procedure or a user-defined function, or a (worst option) a cursor. All these require either create permission or are multi-step processes, and it sounds like you need a single SQL statement.
    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
    One Flump in One Place
    Posts
    14,912
    Only other alternative is to do this at the client. TSQL is much easier to code this though AFAIK.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i don't understand what the big deal is here, guys

    this is the solution:
    Code:
    select one.dealID 
         , ''+one.dealNO+','+two.dealNO as dealNO
      from daTable as one
    inner
      join daTable as two
        on two.dealID = one.dealID
       and two.dealNO >= one.dealNO
     where one.dealID = 1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    C'mon Rudy. We both know that's a hack that's limited to the very specific case of his example. The logic will fail if he ever has more than two records to concatenate.
    I can't tell if you are being serious or not...
    If it's not practically useful, then it's practically useless.

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

Posting Permissions

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