on 07-24-2020 2:29 PM
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?
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank's Konrad STRING_AGG works with me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.