collecting multiple values after join

Dear all,

I have two tables:

Table a

a1 a2

10

20

Table b

b1 b2

10 a

10 -

10 null

10 b

10 c

20 a

I have to fill field a.a2 with values from b.b2

I can join a.a1 to b.b1

Then I need to add all values b2 where a.a1 = b.b1 except if containing null and “-“ separated by ; into a variable.

Every value from b.b2 should appear only once.

Results for my examples

a.a2 for a.a1 = 10 = a; b; c

a.a2 for a.a1 = 20 = a

Any idea is high appreciated :blush:

Thanks for help!

BR,

Heinz