Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Folks,
I'm working with the following problem, below is the table that I'm starting with.
DummyTable:
Load * Inline
[
PersonId, Course
1 , Physics
1 , Chemistry
2 , Fingerpainting
2 , Transmission Maintenance
2 , Alchemy
3 , Magic Tricks
3 , Traffic Guarding 101
]
;
I'm trying to get a table that looks like this, where I CONCAT all the Courses based on their PersonId:
PersonId | CourseList |
1 | Physics, Chemistry |
2 | Fingerpainting, Transmission Maintenance, Alchemy |
3 | Magic Tricks, Traffic Guarding 101 |
I'm completely unsure about how to go about this, even though I swear I've done it in the past.
Any help is greatly appreciated.
Like this
NoConcatenate
load PersonId,
concat(distinct Course,', ') as Course
Resident DummyTable
group by PersonId;
drop table DummyTable;
exit script;
Here you go -
DummyTable:
Load * Inline
[
PersonId, Course
1 , Physics
1 , Chemistry
2 , Fingerpainting
2 , Transmission Maintenance
2 , Alchemy
3 , Magic Tricks
3 , Traffic Guarding 101
]
;
Noconcatenate
Final:
Load PersonId, Concat(Course,',') as CourseList
resident DummyTable
Group By PersonId
;
Drop table DummyTable;
May be directly in the visual -
Like this
NoConcatenate
load PersonId,
concat(distinct Course,', ') as Course
Resident DummyTable
group by PersonId;
drop table DummyTable;
exit script;