Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] rows into column grouped by same ID

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] rows into column grouped by same ID
 Login/Join
 
Gold member
posted
Im new to WebFocus and need a way to get multiple rows with same ID into a column separated by commas grouped by the ID.

--Before
DepId | ProId | ProCodes
1 | 1 | PM
1 | 2 | IM
1 | 3 | SSO
1 | 4 | ECM
2 | 1 | PM
2 | 2 | IM
2 | 3 | SSO
3 | 2 | IM
3 | 3 | SSO
3 | 4 | ECM

--After
DepId | ProductList
1 | PM, IM, SSO, ECM
2 | PM, IM, SSO
3 | IM, SSO, ECM

Here is the SQL code example:

create table #testTable (
DepId int,
ProId int,
ProCode varchar(512)
)

insert into #testTable
select 1, 1, 'PM' union all
select 1, 2, 'IM' union all
select 1, 3, 'SSO' union all
select 1, 4, 'ECM' union all
select 2, 1, 'PM' union all
select 2, 2, 'IM' union all
select 2, 3, 'SSO' union all
select 3, 2, 'IM' union all
select 3, 3, 'SSO' union all
select 3, 4, 'ECM'

--Output before merging rows into grouped by coulumn
select * from #testTable

--Need WebFOCUS code for this output
Select
t1.DepId
,STUFF((Select ', ' + t.ProCode
From #testTable t
where t.DepId = t1.DepId
for XML Path('')
),1,2,'') ProductList
From
#testTable t1
Group by t1.DepId

drop table #testTable

This message has been edited. Last edited by: <Kathryn Henning>,


8007
Windows 7, PDF, Excel
 
Posts: 75 | Registered: September 03, 2013Report This Post
Virtuoso
posted Hide Post
Something like this maybe?
DEFINE FILE xxxx
TXT/A100V = IF DEPID EQ LAST DEPID THEN TXT || ', ' | PROCODES ELSE PROCODES;
END

TABLE FILE xxxx
SUM   TXT
BY    DEPID
END


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Gold member
posted Hide Post
That worked, thanks!


8007
Windows 7, PDF, Excel
 
Posts: 75 | Registered: September 03, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] rows into column grouped by same ID

Copyright © 1996-2020 Information Builders