- How do I combine multiple rows into one comma-separated value in SQL?
- Ask in plain English — 'each customer's product names combined into one comma-separated list.' nlqdb compiles a string aggregate — `STRING_AGG(product_name, ', ' ORDER BY product_name)` in Postgres — groups by the customer, and orders the items inside the aggregate so the list is stable. It runs the query in Postgres and shows the SQL, so you can confirm the delimiter and the ordering.
- What's the difference between STRING_AGG and GROUP_CONCAT?
- They're the same idea in different dialects: `STRING_AGG(expr, delimiter)` in Postgres and SQL Server, `GROUP_CONCAT(expr SEPARATOR ',')` in MySQL, `LISTAGG(expr, ',')` in Oracle. All roll grouped rows into one delimited string. nlqdb targets Postgres, so it compiles `STRING_AGG` and shows it — you don't have to remember which engine spells it which way.
- Why does my concatenated list come back in a random order?
- Because a string aggregate has no inherent order — without an explicit `ORDER BY` inside the aggregate, the database concatenates rows in whatever order it read them, which can change between runs. Put the sort inside the aggregate (`STRING_AGG(name, ', ' ORDER BY name)`), not in the outer query. nlqdb compiles the in-aggregate ordering and shows it in the SQL.
- Can I roll up rows on a Postgres database I already run?
- Yes — connect it with the signed-in BYO connect verb (`nlq db connect`; see /solve/query-existing-postgres-in-natural-language) and ask for the combined list in place, no ETL into a separate store. The honest limits: BYO connect is signed-in only (not the public embed), and the answer is read-only — nlqdb returns the joined string, it doesn't write it back to a column.