How would I use this to only return distinct values concatenated? I thought I could use distinct in a subquery and then use string_agg to query those values, but that doesn't work:
Select STRING_AGG(t0."SO", ',') "SO"
from (
SELECT distinct 1 "SO"
from [table name] t0) t0
If the table you're querying against only has 1 result it will only return 1. But in my case my table has multiple rows. So even though the subquery only returns one result, the whole query returns 1,1,1,1,1,etc.