Skip to Content

hana sql query

Hi experts,

I want to query some data and put it in the same row.

for ex. I have sales orders number 1 to 5 I want to put them in the same cell as that (1,2,3,4,5)

is that possible?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 24, 2020 at 03:31 PM

    You can use STRING_AGG function to concatenate values. Here is an example:

    CREATE LOCAL TEMPORARY TABLE #t1 ("ORDER" VARCHAR(10));
    
    INSERT INTO  #t1 VALUES ('1');
    INSERT INTO  #t1 VALUES ('2');
    INSERT INTO  #t1 VALUES ('3');
    INSERT INTO  #t1 VALUES ('4');
    INSERT INTO  #t1 VALUES ('5');
    
    SELECT STRING_AGG("ORDER",',') FROM #t1;
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2020 at 08:55 PM

    Thank's Konrad STRING_AGG works with me

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.