Let's say I have the following table:
name virtual message
--------------------------
a 1 'm1'
a 1 'm2'
a 0 'm3'
a 0 'm4'
b 1 'm5'
b 0 'm6'
c 0 'm7'
I want to group by name but only concat the message if virtual is 1.
The result I am looking for is:
name concat_message
---------------------
a 'm1,m2'
b 'm5'
c ''
I couldn't find a way to conditionally aggregate using string_agg.
