- How do I pivot rows into columns without writing a crosstab query?
- Ask in plain English — 'revenue per product, one column per month.' nlqdb compiles the conditional aggregation (one `SUM(...) FILTER (WHERE ...)` per output column), runs it in Postgres, and returns the wide table plus the SQL it ran. You get the pivot without hand-writing a CASE expression per column or wiring the `tablefunc` extension. The honest limit: the columns must be ones you can name.
- Does nlqdb use SQL Server's PIVOT keyword or Postgres crosstab?
- Neither by default — nlqdb is Postgres-first, and the portable pivot pattern there is conditional aggregation: `SUM(amount) FILTER (WHERE month = 'Jan')` as one column, repeated per bucket. That needs no `PIVOT` keyword (Postgres has none) and no `tablefunc` extension. The compiled SQL shows under the trace toggle so you can confirm each column maps to the bucket you meant.
- Can I pivot a Postgres database I already run?
- Yes — connect it with the signed-in BYO connect verb (`nlq db connect`, `SK-DBCONN-001`; see /solve/query-existing-postgres-in-natural-language) and ask for the wide report in place, no ETL into a separate store. The honest limits: BYO connect is signed-in only (not the public embed), and nlqdb returns the pivot with a read-only query — it doesn't persist a materialized crosstab for you.
- Why not just pivot in Excel or a spreadsheet?
- A spreadsheet pivot table works once you've exported the rows — but it's a manual copy each refresh, capped by row count, and detached from the live data. Asking nlqdb runs the aggregation in the database against current rows and shows the SQL, so the wide report is reproducible and auditable rather than a stale paste. Export the result to a sheet afterward if you like.