How to create comma separated values in Bold BI PostgreSQL?
In some cases, you may want to create a comma-separated list of values in Bold BI. We can accomplish this using the `string_agg` function in the code view mode.
Using the string_agg Function
Here's a sample query to achieve this:
```sql
SELECT
"idtest"."country" AS "country",
SUM("idtest"."value") AS "value",
string_agg("idtest"."id"::text, ', ') AS "id",
SUM("idtest"."rating") AS "rating"
FROM "public"."idtest" AS "idtest"
GROUP BY "country"
```
In this query, the `string_agg` function is used to concatenate the "id" column values with a comma separator. The result will be a comma-separated list of IDs for each country.
Conclusion
By using the `string_agg` function in Bold BI's code view mode, you can create a comma-separated list of IDs or other values based on your requirements. This can be helpful when you need to display aggregated data with a list of associated values.