- How do I calculate a median in SQL?
- Ask in plain English — 'median revenue per order.' Postgres has no `MEDIAN()` function, so nlqdb compiles the ordered-set aggregate `PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY revenue)`, runs it, and returns the value plus the SQL it ran. You get the middle value without remembering the `WITHIN GROUP` syntax. The honest limit: you have to name a column it can order by.
- What's the difference between PERCENTILE_CONT and PERCENTILE_DISC?
- `PERCENTILE_CONT` interpolates between the two middle rows — the continuous median of [1, 2] is 1.5. `PERCENTILE_DISC` returns an actual value present in the data — the discrete median of [1, 2] is 1. They diverge on even-sized sets and on categorical-but-ordered data. nlqdb shows which one the compiled SQL used so you can confirm you got the one you meant.
- Can I get a p90, p95, or p99 percentile too?
- Yes — they're the same ordered-set aggregate with a different fraction: `PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY latency)` for p90, `0.95` for p95. Ask for 'the 95th percentile of response time' and nlqdb compiles the fraction, then shows the SQL. The honest limit: name the column and the percentile you want.
- Can I compute a median or percentile on 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 summary 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 percentile with a read-only query — it doesn't persist a materialized summary for you.