Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Unanswered: How to output the query in One Row/line

    Hi all,

    I would like to ask on how can I modify the output of my query in sybase into one row only.

    Here's the example:

    Select NAME from TABLE.EMPLOYEE

    Output:

    James
    Peter
    John
    Stephen
    Gary

    I want to make the output to:

    James Peter John Stephen Gary

    Your help would be greatly appreciated.

    Thanks!

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I want to make the output to:

    James Peter John Stephen Gary
    That's not the way databases work. It would be best to just read the data from the database as a set (ie as above) and then format it and whatever fashion you like using an external program. Some versions of sybase have an aggregate function called list() which is similar to MySQL's group_concat function. If you have more than a few employees then your list will get truncated. The output string will be comma separated so you may want to remove these.

Posting Permissions

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