on 2022 Nov 08 11:51 PM
given the below table.
Order Prodname
1 Prody
1 ProdA
2 ProdA
2 ProdX
2 ProdH
How to I convert this to one line per order with the prodnames concatenated into an ordered list:
Order Products
1 ProdA, Prody
2 ProdA, ProdH, ProdX
I can do this easily in SQLServer but not sure how to do this in SAP IQ.
Request clarification before answering.
In IQ demo database:
create table orders_tab(Order_ID unsigned integer, Prod_ID varchar(100)) ;
insert into orders_tab values
(1 ,'Prody'),
(1, 'ProdA'),
(2 ,'ProdA'),
(2 , 'ProdX'),
(2 ,'ProdH') ;
commit ;
Query using LIST :
select Order_ID, LIST(Prod_ID order by Prod_ID) as Products_by_Order
from orders_tab
group by Order_ID
order by Order_ID ;
Result :
Order_ID,Products_by_Order
1,'ProdA,Prody'
2,'ProdA,ProdH,ProdX'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
33 | |
21 | |
16 | |
8 | |
8 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.